I have a timeseries which should be at a daily frequency but has some missing samples. I would like to simply forward-fill any missing values.
Using `resample` with `fill_method='ffill'` works fine for numeric data but fails for non-numeric data (see example below).
Since I'm not asking to do e.g. a linear interpolation there seems no need for this restriction. It is of course possible to create a DatetimeIndex spanning
the range and reindex the series with `method='ffill'` but this seems a bit cumbersome (and inefficient?) and makes it harder to write generic code.
Is there a better way to do what I'm after? If not I'll file an enhancement issue if it's considered appropriate.
In [1]: dates = pd.date_range('01-Jan-2014','05-Jan-2014', freq='D')
...: series = pd.TimeSeries(['a','b','c','d','e'], index=dates)
...: series[[0,1,3,4]].resample('D', fill_method='ffill')
...:
Traceback (most recent call last):
File "<ipython-input-1-7640cf6639de>", line 3, in <module>
series[[0,1,3,4]].resample('D', fill_method='ffill')
File "C:\dev\bin\Python27\lib\site-packages\pandas\core\generic.py", line 189, in resample
return sampler.resample(self)
File "C:\dev\bin\Python27\lib\site-packages\pandas\tseries\resample.py", line 68, in resample
rs = self._resample_timestamps(obj)
File "C:\dev\bin\Python27\lib\site-packages\pandas\tseries\resample.py", line 197, in _resample_timestamps
result = grouped.aggregate(self._agg_method)
File "C:\dev\bin\Python27\lib\site-packages\pandas\core\groupby.py", line 1258, in aggregate
return getattr(self, func_or_funcs)(*args, **kwargs)
File "C:\dev\bin\Python27\lib\site-packages\pandas\core\groupby.py", line 297, in mean
return self._cython_agg_general('mean')
File "C:\dev\bin\Python27\lib\site-packages\pandas\core\groupby.py", line 385, in _cython_agg_general
raise DataError('No numeric types to aggregate')
DataError: No numeric types to aggregate