title: Finding present values in a time frame, pandas
body: <p>I am working with a dataframe that has different products (each one with a different product reference, &quot;PR&quot; in this dataframe) that have a certain time frame in which they were working.</p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import numpy as np
  np.random.seed(123)
  df = pd.DataFrame({ 
      'PR':(&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;,&quot;18&quot;),
      'StartDate':pd.date_range('1/1/2011', periods=6, freq='D'),
      'EndDate':np.random.choice( pd.date_range('1/1/2011', periods=365, 
                            freq='D'), 6, replace=False) 
      })
  </code></pre>
  <p>Which prints out this table</p>
  <pre><code>                PR  StartDate   EndDate
             0    1   2011-01-01  2011-03-01
             1    2   2011-01-02  2011-11-06
             2    3   2011-01-03  2011-01-10
             3    4   2011-01-04  2011-10-27
             4    5   2011-01-05  2011-08-31
             5    18  2011-01-06  2011-06-06
  </code></pre>
  <p>I want to find how many products are alive at any given month (In this case: (2011-01, 1 product alive), (2011-02, 5 products alive),(2011-04, 4 products alive), etc... How can I do this?</p>