title: Average of daily count of records per month in a Pandas DataFrame
body: <p>I have a pandas DataFrame with a <code>TIMESTAMP</code> column, which is of the datetime64 data type. Please keep in mind, initially this column is not set as the index; the index is just regular integers, and the first few rows look like this:</p>
  
  <pre><code>     TIMESTAMP                  TYPE
  0    2014-07-25 11:50:30.640    2
  1    2014-07-25 11:50:46.160    3
  2    2014-07-25 11:50:57.370    2
  </code></pre>
  
  <p>There is an arbitrary number of records for each day, and there may be days with no data. What I am trying to get is the <strong>average number of daily records per month</strong> then plot it as a bar chart with months in the x-axis (April 2014, May 2014... etc.). I managed to calculate these values using the code below</p>
  
  <pre><code>dfWIM.index = dfWIM.TIMESTAMP    
  for i in range(dfWIM.TIMESTAMP.dt.year.min(),dfWIM.TIMESTAMP.dt.year.max()+1):
      for j in range(1,13):
          print dfWIM[(dfWIM.TIMESTAMP.dt.year == i) &amp; (dfWIM.TIMESTAMP.dt.month == j)].resample('D', how='count').TIMESTAMP.mean()
  </code></pre>
  
  <p>which gives the following output:</p>
  
  <pre><code>nan
  nan
  3100.14285714
  6746.7037037
  9716.42857143
  10318.5806452
  9395.56666667
  9883.64516129
  8766.03225806
  9297.78571429
  10039.6774194
  nan
  nan
  nan
  </code></pre>
  
  <p>This is ok as it is, and with some more work, I can map to results to correct month names, then plot the bar chart. However, I am not sure if this is the correct/best way, and I suspect there might be an easier way to get the results using Pandas.</p>
  
  <p>I would be glad to hear what you think. Thanks!</p>
  
  <p><strong>NOTE:</strong> If I do not set the TIMESTAMP column as the index, I get a "reduction operation 'mean' not allowed for this dtype" error.</p>