pandas.PeriodIndex
-
class pandas.PeriodIndex[source] -
Immutable ndarray holding ordinal values indicating regular periods in time such as particular years, quarters, months, etc.
Index keys are boxed to Period objects which carries the metadata (eg, frequency information).
Parameters: data : array-like (1-dimensional), optional
Optional period-like data to construct index with
copy : bool
Make a copy of input ndarray
freq : string or period object, optional
One of pandas period strings or corresponding objects
start : starting value, period-like, optional
If data is None, used as the start point in generating regular period data.
periods : int, optional, > 0
Number of periods to generate, if generating index. Takes precedence over end argument
end : end value, period-like, optional
If periods is none, generated index will extend to first conforming period on or just past end argument
-
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
tz : object, default None
Timezone for converting datetime64 data to Periods
-
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
Examples
>>> idx = PeriodIndex(year=year_arr, quarter=q_arr)
>>> idx2 = PeriodIndex(start='2000', end='2010', freq='A')
Attributes
dayThe days of the period dayofweekThe day of the week with Monday=0, Sunday=6 dayofyearThe ordinal day of the year days_in_monthThe number of days in the month daysinmonthThe number of days in the month freqReturn the frequency object if it is set, otherwise None freqstrReturn the frequency object as a string if it is set, otherwise None hourThe hour of the period is_leap_yearLogical indicating if the date belongs to a leap year minuteThe minute of the period monthThe month as January=1, December=12 quarterThe quarter of the date secondThe second of the period weekThe week ordinal of the year weekdayThe day of the week with Monday=0, Sunday=6 weekofyearThe week ordinal of the year yearThe year of the period end_time qyear start_time Methods
asfreq([freq, how])Convert the PeriodIndex to the specified frequency freq.strftime(date_format)Convert to Index using specified date_format. to_timestamp([freq, how])Cast to DatetimeIndex tz_convert(tz)Convert tz-aware DatetimeIndex from one time zone to another (using pytz/dateutil) tz_localize(tz[, ambiguous])Localize tz-naive DatetimeIndex to given time zone (using pytz/dateutil), or remove timezone from tz-aware DatetimeIndex -
© 2008–2012, 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/0.23.4/generated/pandas.PeriodIndex.html