pandas.PeriodIndex.from_ordinals#
- classmethod PeriodIndex.from_ordinals(ordinals, *, freq, name=None)[source]#
Construct a PeriodIndex from ordinals.
- Parameters:
- ordinalsarray-like of int
The period offsets from the proleptic Gregorian epoch.
- freqstr or period object
One of pandas period strings or corresponding objects.
- namestr, default None
Name of the resulting PeriodIndex.
- Returns:
- PeriodIndex
See also
PeriodIndex.from_fields
Construct a PeriodIndex from fields (year, month, day, etc.).
PeriodIndex.to_timestamp
Cast to DatetimeArray/Index.
Examples
>>> idx = pd.PeriodIndex.from_ordinals([-1, 0, 1], freq="Q") >>> idx PeriodIndex(['1969Q4', '1970Q1', '1970Q2'], dtype='period[Q-DEC]')