pandas.PeriodIndex.from_fields#

classmethod PeriodIndex.from_fields(*, year=None, quarter=None, month=None, day=None, hour=None, minute=None, second=None, freq=None)[source]#

Construct a PeriodIndex from fields (year, month, day, etc.).

Parameters:
yearint, array, or Series, default None
quarterint, array, or Series, default None
monthint, array, or Series, default None
dayint, array, or Series, default None
hourint, array, or Series, default None
minuteint, array, or Series, default None
secondint, array, or Series, default None
freqstr or period object, optional

One of pandas period strings or corresponding objects.

Returns:
PeriodIndex

Examples

>>> idx = pd.PeriodIndex.from_fields(year=[2000, 2002], quarter=[1, 3])
>>> idx
PeriodIndex(['2000Q1', '2002Q3'], dtype='period[Q-DEC]')