Table Of Contents

Search

Enter search terms or a module, class or function name.

pandas.PeriodIndex.asfreq

PeriodIndex.asfreq(freq=None, how='E')[source]

Convert the PeriodIndex to the specified frequency freq.

Parameters:

freq : str

a frequency

how : str {‘E’, ‘S’}

‘E’, ‘END’, or ‘FINISH’ for end, ‘S’, ‘START’, or ‘BEGIN’ for start. Whether the elements should be aligned to the end or start within pa period. January 31st (‘END’) vs. Janury 1st (‘START’) for example.

Returns:
new : PeriodIndex with the new frequency

Examples

>>> pidx = pd.period_range('2010-01-01', '2015-01-01', freq='A')
>>> pidx
<class 'pandas.core.indexes.period.PeriodIndex'>
[2010, ..., 2015]
Length: 6, Freq: A-DEC
>>> pidx.asfreq('M')
<class 'pandas.core.indexes.period.PeriodIndex'>
[2010-12, ..., 2015-12]
Length: 6, Freq: M
>>> pidx.asfreq('M', how='S')
<class 'pandas.core.indexes.period.PeriodIndex'>
[2010-01, ..., 2015-01]
Length: 6, Freq: M
Scroll To Top