Skip to content

Commit 05eb967

Browse files
committed
DOC: add docstring for PeriodIndex.asfreq
1 parent 6c80f68 commit 05eb967

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

pandas/tseries/period.py

+38
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,44 @@ 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+
Whether the elements should be aligned to the end
370+
or start within pa period. January 31st ('END') vs.
371+
Janury 1st ('START') for example.
372+
373+
Returns
374+
-------
375+
376+
new : PeriodIndex with the new frequency
377+
378+
Examples
379+
--------
380+
>>> pidx = pd.period_range('2010-01-01', '2015-01-01', freq='A')
381+
>>> pidx
382+
<class 'pandas.tseries.period.PeriodIndex'>
383+
[2010, ..., 2015]
384+
Length: 6, Freq: A-DEC
385+
386+
>>> pidx.asfreq('M')
387+
<class 'pandas.tseries.period.PeriodIndex'>
388+
[2010-12, ..., 2015-12]
389+
Length: 6, Freq: M
390+
391+
>>> pidx.asfreq('M', how='S')
392+
<class 'pandas.tseries.period.PeriodIndex'>
393+
[2010-01, ..., 2015-01]
394+
Length: 6, Freq: M
395+
"""
358396
how = _validate_end_alias(how)
359397

360398
freq = frequencies.get_standard_freq(freq)

0 commit comments

Comments
 (0)