Skip to content

Commit 8904245

Browse files
committed
Revert "Revert "ENH pandas-dev#3715 specify arguments to _upsample""
This reverts commit 6f3fed3.
1 parent c367d80 commit 8904245

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4083,7 +4083,7 @@ def asfreq(self, freq, method=None, how=None, normalize=False,
40834083
Value to use for missing values, applied during upsampling (note
40844084
this does not fill NaNs that already were present).
40854085
4086-
.. version added:: 0.20.0
4086+
.. versionadded:: 0.20.0
40874087
40884088
Returns
40894089
-------

pandas/tseries/resample.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def transform(self, arg, *args, **kwargs):
352352
def _downsample(self, f):
353353
raise AbstractMethodError(self)
354354

355-
def _upsample(self, f, limit=None):
355+
def _upsample(self, f, limit=None, fill_value=None):
356356
raise AbstractMethodError(self)
357357

358358
def _gotitem(self, key, ndim, subset=None):
@@ -499,12 +499,21 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
499499
limit_direction=limit_direction,
500500
downcast=downcast, **kwargs)
501501

502-
def asfreq(self, **kwargs):
502+
def asfreq(self, fill_value=None):
503503
"""
504504
return the values at the new freq,
505-
essentially a reindex with (no filling)
505+
essentially a reindex
506+
507+
Parameters
508+
----------
509+
fill_value: scalar, optional
510+
Value to use for missing values, applied during upsampling (note
511+
this does not fill NaNs that already were present).
512+
513+
.. versionadded:: 0.20.0
514+
506515
"""
507-
return self._upsample('asfreq', **kwargs)
516+
return self._upsample('asfreq', fill_value=fill_value)
508517

509518
def std(self, ddof=1, *args, **kwargs):
510519
"""
@@ -710,6 +719,8 @@ def _upsample(self, method, limit=None, fill_value=None):
710719
'ffill', 'asfreq'} method for upsampling
711720
limit : int, default None
712721
Maximum size gap to fill when reindexing
722+
fill_value : scalar, default None
723+
Value to use for missing values
713724
714725
See also
715726
--------
@@ -855,12 +866,14 @@ def _downsample(self, how, **kwargs):
855866
'Frequency {} cannot be resampled to {}, as they are not '
856867
'sub or super periods'.format(ax.freq, self.freq))
857868

858-
def _upsample(self, method, limit=None):
869+
def _upsample(self, method, limit=None, fill_value=None):
859870
"""
860871
method : string {'backfill', 'bfill', 'pad', 'ffill'}
861872
method for upsampling
862873
limit : int, default None
863874
Maximum size gap to fill when reindexing
875+
fill_value : scalar, default None
876+
Value to use for missing values
864877
865878
See also
866879
--------

0 commit comments

Comments
 (0)