You are viewing documentation about an older version (1.22.1). View latest version

modin.pandas.Resampler.fillnaΒΆ

Resampler.fillna(method: str, limit: Optional[int] = None)[source]ΒΆ

Fill missing values introduced by upsampling. Missing values that existed in the original data will not be modified.

Parameters:
  • method ({'pad', 'backfill', 'ffill', 'bfill', 'nearest'}) – Method to use for filling holes in resampled data. Note that only β€˜ffill’ and β€˜pad’ are currently supported. β€˜pad’ or β€˜ffill’: use previous valid observation to fill gap (forward fill). β€˜backfill’ or β€˜bfill’: use next valid observation to fill gap. β€˜nearest’: use nearest valid observation to fill gap.

  • limit (int, optional) – This parameter is not supported and will raise NotImplementedError.

Returns:

An upsampled Series or DataFrame with missing values filled.

Return type:

Series or DataFrame

Examples

>>> s = pd.Series([1, 2, 3], index=pd.date_range('20180101', periods=3, freq='h'))
>>> s
2018-01-01 00:00:00    1
2018-01-01 01:00:00    2
2018-01-01 02:00:00    3
Freq: None, dtype: int64
>>> s.resample('30min').fillna("pad")
2018-01-01 00:00:00    1
2018-01-01 00:30:00    1
2018-01-01 01:00:00    2
2018-01-01 01:30:00    2
2018-01-01 02:00:00    3
Freq: None, dtype: int64
>>> s.resample('30min').fillna("backfill")
2018-01-01 00:00:00    1
2018-01-01 00:30:00    2
2018-01-01 01:00:00    2
2018-01-01 01:30:00    3
2018-01-01 02:00:00    3
Freq: None, dtype: int64
>>> sm = pd.Series([1, None, 3],
... index=pd.date_range('20180101', periods=3, freq='h'))
>>> sm
2018-01-01 00:00:00    1.0
2018-01-01 01:00:00    NaN
2018-01-01 02:00:00    3.0
Freq: None, dtype: float64
>>> sm.resample('30min').fillna('pad')
2018-01-01 00:00:00    1.0
2018-01-01 00:30:00    1.0
2018-01-01 01:00:00    NaN
2018-01-01 01:30:00    NaN
2018-01-01 02:00:00    3.0
Freq: None, dtype: float64
>>> sm.resample('30min').fillna('backfill')
2018-01-01 00:00:00    1.0
2018-01-01 00:30:00    NaN
2018-01-01 01:00:00    NaN
2018-01-01 01:30:00    3.0
2018-01-01 02:00:00    3.0
Freq: None, dtype: float64
Copy