pandas.PeriodIndex — pandas 3.0.0rc0+33.g1fd184de2a documentation (original) (raw)
class pandas.PeriodIndex(data=None, freq=None, dtype=None, copy=False, name=None)[source]#
Immutable ndarray holding ordinal values indicating regular periods in time.
Index keys are boxed to Period objects which carries the metadata (eg, frequency information).
Parameters:
dataarray-like (1d int np.ndarray or PeriodArray), optional
Optional period-like data to construct index with.
freqstr or period object, optional
One of pandas period strings or corresponding objects.
dtypestr or PeriodDtype, default None
A dtype from which to extract a freq.
copybool
Make a copy of input ndarray.
namestr, default None
Name of the resulting PeriodIndex.
Attributes
Methods
Raises:
ValueError
Passing the parameter data as a list without specifying either freq or dtype will raise a ValueError: “freq not specified and cannot be inferred”
Examples
idx = pd.PeriodIndex(data=["2000Q1", "2002Q3"], freq="Q") idx PeriodIndex(['2000Q1', '2002Q3'], dtype='period[Q-DEC]')