Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.period_range#

pandas.period_range(start=None,end=None,periods=None,freq=None,name=None)[source]#

Return a fixed frequency PeriodIndex.

The day (calendar) is the default frequency.

Parameters:
startstr, datetime, date, pandas.Timestamp, or period-like, default None

Left bound for generating periods.

endstr, datetime, date, pandas.Timestamp, or period-like, default None

Right bound for generating periods.

periodsint, default None

Number of periods to generate.

freqstr or DateOffset, optional

Frequency alias. By default the freq is taken fromstart orendif those are Period objects. Otherwise, the default is"D" fordaily frequency.

namestr, default None

Name of the resulting PeriodIndex.

Returns:
PeriodIndex

Notes

Of the three parameters:start,end, andperiods, exactly twomust be specified.

To learn more about the frequency strings, please seethis link.

Examples

>>>pd.period_range(start='2017-01-01',end='2018-01-01',freq='M')PeriodIndex(['2017-01', '2017-02', '2017-03', '2017-04', '2017-05', '2017-06',         '2017-07', '2017-08', '2017-09', '2017-10', '2017-11', '2017-12',         '2018-01'],        dtype='period[M]')

Ifstart orend arePeriod objects, they will be used as anchorendpoints for aPeriodIndex with frequency matching that of theperiod_range constructor.

>>>pd.period_range(start=pd.Period('2017Q1',freq='Q'),...end=pd.Period('2017Q2',freq='Q'),freq='M')PeriodIndex(['2017-03', '2017-04', '2017-05', '2017-06'],            dtype='period[M]')

[8]ページ先頭

©2009-2025 Movatter.jp