I have a data frame with a name austhat looks like this:
+--------------+-------------+
| | link clicks |
+--------------+-------------+
| created_time | |
| 2015-07-20 | 8600 |
| 2015-07-21 | 11567 |
| 2015-07-22 | 1809 |
| 2015-07-23 | 7032 |
| 2015-07-26 | 23704 |
+--------------+-------------+
I am making the DateTimeIndex index as follows:
aus.index = pd.to_datetime(aus.index)
Then I run the test as follows:, type(aus.index)and this outputpandas.tseries.index.DatetimeIndex
Then, when I try to recalculate the index in a few weeks,
aus.index = aus.resample('w', how='sum', axis=1)I encounter the following error:
TypeError Traceback (most recent call last)
<ipython-input-310-3268a3f46a19> in <module>()
/usr/local/lib/python2.7/site-packages/pandas/core/generic.pyc in resample(self, rule, how, axis, fill_method, closed, label, convention, kind, loffset, limit, base)
3264 fill_method=fill_method, convention=convention,
3265 limit=limit, base=base)
-> 3266 return sampler.resample(self).__finalize__(self)
3267
3268 def first(self, offset):
/usr/local/lib/python2.7/site-packages/pandas/tseries/resample.pyc in resample(self, obj)
100 return self.obj
101 else:
103
104 rs_axis = rs._get_axis(self.axis)
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex
Earlier, my check type says that I have the correct index, but the resample function does not think so. Any thoughts?