pandas.PeriodIndex
- class pandas.PeriodIndex(data=None, ordinal=None, freq=None, dtype=None, copy=False, name=None, **fields)[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
-
- data:array-like (1d int np.ndarray or PeriodArray), optional
-
Optional period-like data to construct index with.
- copy:bool
-
Make a copy of input ndarray.
- freq:str or period object, optional
-
One of pandas period strings or corresponding objects.
- year:int, array, or Series, default None
- month:int, array, or Series, default None
- quarter:int, array, or Series, default None
- day:int, array, or Series, default None
- hour:int, array, or Series, default None
- minute:int, array, or Series, default None
- second:int, array, or Series, default None
- dtype:str or PeriodDtype, default None
See also
Index
-
The base pandas Index type.
Period
-
Represents a period of time.
DatetimeIndex
-
Index with datetime64 data.
TimedeltaIndex
-
Index of timedelta64 data.
period_range
-
Create a fixed-frequency PeriodIndex.
Examples
>>> idx = pd.PeriodIndex(year=[2000, 2002], quarter=[1, 3]) >>> idx PeriodIndex(['2000Q1', '2002Q3'], dtype='period[Q-DEC]')
Attributes
The days of the period.
The day of the week with Monday=0, Sunday=6.
The day of the week with Monday=0, Sunday=6.
The ordinal day of the year.
The ordinal day of the year.
The number of days in the month.
The number of days in the month.
Return the frequency object if it is set, otherwise None.
Return the frequency object as a string if its set, otherwise None.
The hour of the period.
Logical indicating if the date belongs to a leap year.
The minute of the period.
The month as January=1, December=12.
The quarter of the date.
The second of the period.
The week ordinal of the year.
The day of the week with Monday=0, Sunday=6.
The week ordinal of the year.
The year of the period.
end_time
qyear
start_time
Methods
asfreq
([freq, how])Convert the PeriodArray to the specified frequency freq.
strftime
(*args, **kwargs)Convert to Index using specified date_format.
to_timestamp
([freq, how])Cast to DatetimeArray/Index.
© 2008–2021, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.3.4/reference/api/pandas.PeriodIndex.html