Pandas Series: asfreq() function

Convert Pandas TimeSeries to specified frequency

The asfreq() function is used to convert TimeSeries to specified frequency.

Optionally provide filling method to pad/backfill missing values.

Returns the original data conformed to a new index with the specified frequency. resample is more appropriate if an operation, such as summarization, is necessary to represent the data at the new frequency.


Series.asfreq(self, freq, method=None, how=None, normalize=False, fill_value=None)
Pandas Series asfreq image


Name Description Type/Default Value Required / Optional
freq DateOffset object, or string Required
method Method to use for filling holes in reindexed Series (note this does not fill NaNs that already were present):
  • 'pad' / 'ffill': propagate last valid observation forward to next valid
  • 'backfill' / 'bfill': use NEXT valid observation to fill
{'backfill'/'bfill', 'pad'/'ffill'}
Default Value: None
how For PeriodIndex only, see PeriodIndex.asfreq {'start', 'end'}
Default Value: end
normalize Whether to reset output index to midnight bool
Default Value: False
fill_value Value to use for missing values, applied during upsampling (note this does not fill NaNs that already were present). scalar Optional

Returns: converted - same type as caller


Download the above Notebook from here.

Previous: Modify Pandas series in place using non-NA values
Next: Get the last row(s) without any NaNs in Pandas series