ENH: Add fill_value option to resample() #3715

Closed
gerdemb opened this Issue May 30, 2013 · 3 comments

Comments

Projects
None yet
3 participants

gerdemb commented May 30, 2013

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

jreback added the API Design label Mar 11, 2014

@jreback jreback modified the milestone: 0.15.0, 0.14.0 Mar 11, 2014

@jreback jreback modified the milestone: 0.16.0, Next Major Release Mar 3, 2015

Contributor

nchmura4 commented Oct 31, 2016

wouldn't this be the right way to do this?
s.resample('M').sum().fillna(0)

Contributor

jreback commented Oct 31, 2016

@nchmura4 that is a way, but this issue is about filling before reindexing, like .reindex provides.

e.g. compare this

In [9]: s.reindex(pd.date_range(s.index.min(), s.index.max(), freq='D'), fill_value=0).resample('M').sum()
Out[9]:
2013-01-31    3
2013-02-28    0
2013-03-31    4
Freq: M, dtype: int64

In [10]: s.reindex(pd.date_range(s.index.min(), s.index.max(), freq='D'), fill_value=1).resample('M').sum()
Out[10]:
2013-01-31    32
2013-02-28    28
2013-03-31     4
Freq: M, dtype: int64
Contributor

nchmura4 commented Oct 31, 2016

got it. thanks for the clarification!

nchmura4 referenced this issue Nov 5, 2016

Closed

ENH: add fill_value to resample #14591

4 of 4 tasks complete

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Nov 25, 2016

@nchmura4 nchmura4 ENH #3715: add documentation and tests 9d226f8

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Nov 29, 2016

@nchmura4 nchmura4 ENH #3715: add documentation 17eb233

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Nov 30, 2016

@nchmura4 nchmura4 ENH #3715 specify arguments to _upsample 9677f06

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 2, 2016

@nchmura4 nchmura4 ENH #3715: add documentation and tests b97d6c8

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 2, 2016

@nchmura4 nchmura4 ENH #3715: add documentation 13a31a1

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 2, 2016

@nchmura4 nchmura4 ENH #3715 specify arguments to _upsample b9ffc14

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 2, 2016

@nchmura4 nchmura4 Revert "ENH #3715 specify arguments to _upsample"
This reverts commit b9ffc14.
6f3fed3

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 2, 2016

@nchmura4 nchmura4 Revert "Revert "ENH #3715 specify arguments to _upsample""
This reverts commit 6f3fed3.
c8cd7f2

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 ENH #3715: add documentation and tests 71dce7d

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 ENH #3715: add documentation 056ba9a

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 ENH #3715 specify arguments to _upsample 1f998dd

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 Revert "ENH #3715 specify arguments to _upsample"
This reverts commit b9ffc14.
b7c70f3

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 Revert "Revert "ENH #3715 specify arguments to _upsample""
This reverts commit 6f3fed3.
aab4497

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 ENH #3715: add documentation and tests 2227cfd

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 ENH #3715: add documentation 7b487fc

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 ENH #3715 specify arguments to _upsample 0fd1914

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 Revert "ENH #3715 specify arguments to _upsample"
This reverts commit b9ffc14.
a681a3e

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 3, 2016

@nchmura4 nchmura4 Revert "Revert "ENH #3715 specify arguments to _upsample""
This reverts commit 6f3fed3.
87448b4

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 21, 2016

@nchmura4 nchmura4 ENH #3715: add documentation and tests 4aa4b08

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 21, 2016

@nchmura4 nchmura4 ENH #3715: add documentation fd810f0

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 21, 2016

@nchmura4 nchmura4 ENH #3715 specify arguments to _upsample f11dc33

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 21, 2016

@nchmura4 nchmura4 Revert "ENH #3715 specify arguments to _upsample"
This reverts commit b9ffc14.
c367d80

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 21, 2016

@nchmura4 nchmura4 Revert "Revert "ENH #3715 specify arguments to _upsample""
This reverts commit 6f3fed3.
8904245

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 31, 2016

@nchmura4 nchmura4 ENH #3715: add documentation and tests f7ccc8a

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 31, 2016

@nchmura4 nchmura4 ENH #3715: add documentation ec49da2

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 31, 2016

@nchmura4 nchmura4 ENH #3715 specify arguments to _upsample b294e7d

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 31, 2016

@nchmura4 nchmura4 Revert "ENH #3715 specify arguments to _upsample"
This reverts commit b9ffc14.
c316a00

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Dec 31, 2016

@nchmura4 nchmura4 Revert "Revert "ENH #3715 specify arguments to _upsample""
This reverts commit 6f3fed3.
c35c717

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Jan 18, 2017

@nchmura4 nchmura4 ENH: add fill_value to asfreq, see #3715 45a9e8e

@nchmura4 nchmura4 added a commit to nchmura4/pandas that referenced this issue Jan 18, 2017

@nchmura4 nchmura4 ENH: add fill_value to asfreq, see #3715 08b6b28

@jreback jreback modified the milestone: 0.20.0, Next Major Release Jan 21, 2017

jreback closed this in 2540d5a Jan 21, 2017

@AnkurDedania AnkurDedania added a commit to AnkurDedania/pandas that referenced this issue Mar 21, 2017

@nchmura4 @AnkurDedania nchmura4 + AnkurDedania ENH: add fill_value to asfreq
closes #3715
closes #14791
4c4bf21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment