In [42]:
%matplotlib inline

import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt

In [45]:
df = pd.read_csv('data/tweets.csv', index_col='timestamp',
                 usecols=['timestamp', 'text'],
                 parse_dates=['timestamp'])

df.head()


Out[45]:
text
timestamp
2017-06-13 18:10:21 RT @gtalug: #GTALUG meeting tonight at 7:30pm....
2017-06-13 18:05:56 Just your weekly reminder how fucking awesome ...
2017-06-13 18:05:24 RT @philsadelphia: the wonder woman theme was ...
2017-06-13 18:05:00 RT @Urban_struggle: Best pic of 2017 https://t...
2017-06-13 17:55:00 RT @zackwhittaker: Just in: Microsoft has issu...

In [52]:
by_year = df.resample('M').mean()

by_year.head()


---------------------------------------------------------------------------
DataError                                 Traceback (most recent call last)
<ipython-input-52-c46cc40dfc53> in <module>()
----> 1 by_year = df.resample('M').mean()
      2 
      3 by_year.head()

/usr/local/lib/python3.6/site-packages/pandas/core/resample.py in f(self, _method, *args, **kwargs)
    559     def f(self, _method=method, *args, **kwargs):
    560         nv.validate_resampler_func(_method, args, kwargs)
--> 561         return self._downsample(_method)
    562     f.__doc__ = getattr(GroupBy, method).__doc__
    563     setattr(Resampler, method, f)

/usr/local/lib/python3.6/site-packages/pandas/core/resample.py in _downsample(self, how, **kwargs)
    712         # we want to call the actual grouper method here
    713         result = obj.groupby(
--> 714             self.grouper, axis=self.axis).aggregate(how, **kwargs)
    715 
    716         result = self._apply_loffset(result)

/usr/local/lib/python3.6/site-packages/pandas/core/groupby.py in aggregate(self, arg, *args, **kwargs)
   4034         versionadded=''))
   4035     def aggregate(self, arg, *args, **kwargs):
-> 4036         return super(DataFrameGroupBy, self).aggregate(arg, *args, **kwargs)
   4037 
   4038     agg = aggregate

/usr/local/lib/python3.6/site-packages/pandas/core/groupby.py in aggregate(self, arg, *args, **kwargs)
   3466 
   3467         _level = kwargs.pop('_level', None)
-> 3468         result, how = self._aggregate(arg, _level=_level, *args, **kwargs)
   3469         if how is None:
   3470             return result

/usr/local/lib/python3.6/site-packages/pandas/core/base.py in _aggregate(self, arg, *args, **kwargs)
    433         if isinstance(arg, compat.string_types):
    434             return self._try_aggregate_string_function(arg, *args,
--> 435                                                        **kwargs), None
    436 
    437         if isinstance(arg, dict):

/usr/local/lib/python3.6/site-packages/pandas/core/base.py in _try_aggregate_string_function(self, arg, *args, **kwargs)
    389         if f is not None:
    390             if callable(f):
--> 391                 return f(*args, **kwargs)
    392 
    393             # people may try to aggregate on a non-callable attribute

/usr/local/lib/python3.6/site-packages/pandas/core/groupby.py in mean(self, *args, **kwargs)
   1035         nv.validate_groupby_func('mean', args, kwargs, ['numeric_only'])
   1036         try:
-> 1037             return self._cython_agg_general('mean', **kwargs)
   1038         except GroupByError:
   1039             raise

/usr/local/lib/python3.6/site-packages/pandas/core/groupby.py in _cython_agg_general(self, how, alt, numeric_only)
   3352     def _cython_agg_general(self, how, alt=None, numeric_only=True):
   3353         new_items, new_blocks = self._cython_agg_blocks(
-> 3354             how, alt=alt, numeric_only=numeric_only)
   3355         return self._wrap_agged_blocks(new_items, new_blocks)
   3356 

/usr/local/lib/python3.6/site-packages/pandas/core/groupby.py in _cython_agg_blocks(self, how, alt, numeric_only)
   3423 
   3424         if len(new_blocks) == 0:
-> 3425             raise DataError('No numeric types to aggregate')
   3426 
   3427         # reset the locs in the blocks to correspond to our

DataError: No numeric types to aggregate

In [ ]: