title: How to get the mode for string variable when resampling with pandas
body: <p>I am trying to resample a pandas data frame with a timestamp index to an hourly occurrence. I am interested in obtaining the most frequent value for a column with string values . However the built in functions of time series resampling do not include mode as one of the default methods to resample (as it does 'mean' and 'count').<br>
  I tried to define my own function and to pass that function but is not working. I've also tried using the <code>np.bincount</code> function but it does not work since I am working with strings.</p>
  
  <p>Here is how my data looks:</p>
  
  <pre><code>                   station_arrived action     lat1     lon1
  date_removed
  2012-01-01 13:12:00     56             A     19.4171 -99.16561   
  2012-01-01 13:12:00     56             A     19.4271 -99.16361 
  2012-01-01 15:41:00     56             A     19.4171 -99.16561 
  2012-01-02 08:41:00     56             C     19.4271 -99.16561 
  2012-01-02 11:36:00     56             C     19.2171 -99.16561
  </code></pre>
  
  <p>This is my code so far:</p>
  
  <pre><code>def mode1(algo):
      common=[ite for ite, it in Counter(algo).most_common(1)]
      # Returns all unique items and their counts
      return common
  
  hourlycount2 = travels2012.resample('H', how={'station_arrived': 'count',
                                                'action': mode(travels2012['action']),
                                                'lat1':'count', 'lon1':'count'})
  
  hourlycount2.head()
  </code></pre>
  
  <p>I see the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 3, in &lt;module&gt;
    File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\generic.py", line 2836, in resample
      return sampler.resample(self).__finalize__(self)
    File "C:\Program Files\Anaconda\lib\site-packages\pandas\tseries\resample.py", line 83, in resample
      rs = self._resample_timestamps()
    File "C:\Program Files\Anaconda\lib\site-packages\pandas\tseries\resample.py", line 277, in _resample_timestamps
      result = grouped.aggregate(self._agg_method)
    File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\groupby.py", line 2404, in aggregate
      result[col] = colg.aggregate(agg_how)
    File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\groupby.py", line 2076, in aggregate
      ret = self._aggregate_multiple_funcs(func_or_funcs)
    File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\groupby.py", line 2125, in _aggregate_multiple_funcs
      results[name] = self.aggregate(func)
    File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\groupby.py", line 2073, in aggregate
      return getattr(self, func_or_funcs)(*args, **kwargs)
    File "C:\Program Files\Anaconda\lib\site-packages\pandas\core\groupby.py", line 486, in __getattr__
      (type(self).__name__, attr))
  AttributeError: 'SeriesGroupBy' object has no attribute 'A  '
  </code></pre>