title: insert new non-existing column in how= of resample
body: <p>I was reading <a href="https://stackoverflow.com/questions/10020591/how-to-resample-a-dataframe-with-different-functions-applied-to-each-column">resample a dataframe with different functions applied to each column?</a></p>
  
  <p>The solution was:</p>
  
  <pre><code>frame.resample('1H', how={'radiation': np.sum, 'tamb': np.mean})
  </code></pre>
  
  <p>Say if I want to add a non-existing column to the result that stores the value of some other function, say count(). In the example given, say if I want to compute the number of rows in each 1H period.</p>
  
  <p>Is it possible to do:</p>
  
  <pre><code>frame.resample('1H', how={'radiation': np.sum, 'tamb': np.mean,\
                 'new_column': count()})
  </code></pre>
  
  <p>Note, new_column is NOT an existing column in the original data frame.</p>
  
  <p>The reason why I ask, is I need to do this and I have a very large data frame and I don't want to resample the original df twice just to get the count in the resample period. </p>
  
  <p>I'm trying the above right now and it seems to be taking a very long time (no syntax errors). Not sure if python is trapped in some sort of forever loop.</p>
  
  <p>Update:</p>
  
  <p>I implemented the suggestion to use agg (thank you kindly for that).</p>
  
  <p>However, I received the following error when computing the first aggregator:</p>
  
  <pre><code>grouped = df.groupby(['name1',pd.TimeGrouper('M')])
      return pd.DataFrame(
      {'new_col1': grouped['col1'][grouped['col1'] &gt; 0].agg('sum')
      ...
  
  
  /Users/blahblah/anaconda/lib/python2.7/site-packages/pandas/core/groupby.pyc in __getitem__(self, key)
      521 
      522     def __getitem__(self, key):
  --&gt; 523         raise NotImplementedError('Not implemented: %s' % key)
      524 
      525     def _make_wrapper(self, name):
  
  NotImplementedError: Not implemented: True
  </code></pre>
  
  <p>The following works when I use <code>grouped.apply(foo)</code>.</p>
  
  <pre><code>new_col1 = grp['col1'][grp['col1'] &gt; 0].sum()
  </code></pre>