title: Get count by day given time periods
body: <p>Sample dataframe:</p>
  
  <pre><code>    id           start1        end1      start2        end2
  0  Bob       2018-11-29  2018-11-30  2018-12-01  2018-12-31
  1  James     2018-10-19  2018-10-31         NaT         NaT
  2  Jane      2018-04-05  2018-07-12  2018-11-29  2018-11-30
  </code></pre>
  
  <p>Given the above sample dataframe, I'd like to show a frequency count by month and year. Let's assume that during these periods each person (<code>id</code>) was "affected" by something. There are up to two time periods for each person (there will always be at least one time period (i.e., <code>start1</code> and <code>end1</code>), but there may or may not be a second (i.e., <code>start2</code> and <code>end2</code>)). I want to show how many people were affected by month and year during the entire time frame that anyone was affected.</p>
  
  <p>For example, the above data would result in something like this (not sure if year-month would be same column or multiple&mdash;whatever works):</p>
  
  <pre><code>   year-month  count
  0     2018-04      1
  1     2018-05      1
  2     2018-06      1
  3     2018-07      1
  4     2018-08      0
  5     2018-09      0
  6     2018-10      1
  7     2018-11      2
  8     2018-12      1
  </code></pre>
  
  <p>My eventual goal would be to look at these across different time periods (e.g., year (all are in 2018 in this example data), month/year, week, etc.).</p>
  
  <p>I am not sure how to go about unpacking these into a single series so I can do a histogram on a single column. I know once I have them in a single column (e.g., <code>date</code>) I could do something like:</p>
  
  <pre><code>df.groupby(df["date"].dt.month).count().plot(kind="bar")
  </code></pre>
  
  <p>But that would only be by month, and it assumes I already have the dates in a single column.</p>
  
  <p>I could just use <code>datetime</code> and keep adding days in a loop if it is between each time frame until I get to the end date, but every time I do something like that I learn that pandas/numpy has a better way. <strong>I'm looking for that better way.</strong></p>