pandas.
period_range
Return a fixed frequency PeriodIndex.
The day (calendar) is the default frequency.
Left bound for generating periods.
Right bound for generating periods.
Number of periods to generate.
Frequency alias. By default the freq is taken from start or end if those are Period objects. Otherwise, the default is "D" for daily frequency.
"D"
Name of the resulting PeriodIndex.
Notes
Of the three parameters: start, end, and periods, exactly two must be specified.
start
end
periods
To learn more about the frequency strings, please see this 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-06', '2017-07', '2017-08', '2017-09', '2017-10', '2017-11', '2017-12', '2018-01'], dtype='period[M]', freq='M')
If start or end are Period objects, they will be used as anchor endpoints for a PeriodIndex with frequency matching that of the period_range constructor.
Period
PeriodIndex
>>> 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]', freq='M')