Skip to content

ENH: Add fill_value option to resample() #3715

@gerdemb

Description

@gerdemb

see also #3707

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignDtype ConversionsUnexpected or buggy dtype conversionsMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateResampleresample method

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions