Skip to content

Commit d6f20b4

Browse files
committed
DOC: add PeriodIndex.asfreq docstring
1 parent 4b58538 commit d6f20b4

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pandas/tseries/period.py

+31
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,37 @@ def freqstr(self):
355355
return self.freq
356356

357357
def asfreq(self, freq=None, how='E'):
358+
"""
359+
Convert the PeriodIndex to the specified frequency `freq`.
360+
361+
Parameters
362+
----------
363+
364+
freq : str
365+
a frequency
366+
how : str {'E', 'S'}
367+
'E', 'END', or 'FINISH' for end,
368+
'S', 'START', or 'BEGIN' for start.
369+
370+
Returns
371+
-------
372+
373+
new: PeriodIndex with the new frequency
374+
375+
Examples
376+
--------
377+
378+
>>> pidx = pd.period_range('2010-01-01', '2015-01-01', freq='A')
379+
>>> pidx.asfreq('M')
380+
<class 'pandas.tseries.period.PeriodIndex'>
381+
[2010-12, ..., 2015-12]
382+
Length: 6, Freq: M
383+
384+
>>> pidx.asfreq('M', how='S')
385+
<class 'pandas.tseries.period.PeriodIndex'>
386+
[2010-01, ..., 2015-01]
387+
Length: 6, Freq: M
388+
"""
358389
how = _validate_end_alias(how)
359390

360391
freq = frequencies.get_standard_freq(freq)

0 commit comments

Comments
 (0)