ENH: Add fill_value option to resample() · Issue #3715 · pandas-dev/pandas (original) (raw)

Add a fill_value option to resample() so that it is possible to resample a TimeSeries without creating NaN values. If the series is an int dtype and an int is passed to fill_value, it should be possible to resample the series without casting the values to floats.

>>> dates = (datetime(2013, 1, 1), datetime(2013,1,2), datetime(2013,3,1))
>>> s = Series([1,2,4],index=dates)
>>> s
2013-01-01    1
2013-01-02    2
2013-03-01    4
dtype: int64
>>> s.resample('M', how='sum')
2013-01-31     3
2013-02-28   NaN
2013-03-31     4
Freq: M, dtype: float64
>>> s.resample('M', how='sum', fill_value=0)
2013-01-31     3
2013-02-28     0
2013-03-31     4
Freq: M, dtype: int64