pandas.PeriodIndex.from_fields — pandas 3.0.0rc0+52.gb43b95d2b4 documentation (original) (raw)

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

Year for the PeriodIndex.

quarterint, array, or Series, default None

Quarter for the PeriodIndex.

monthint, array, or Series, default None

Month for the PeriodIndex.

dayint, array, or Series, default None

Day for the PeriodIndex.

hourint, array, or Series, default None

Hour for the PeriodIndex.

minuteint, array, or Series, default None

Minute for the PeriodIndex.

secondint, array, or Series, default None

Second for the PeriodIndex.

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]')