pandas.Period — pandas 3.0.0.dev0+2097.gcdc5b7418e documentation (original) (raw)

class pandas.Period(value=None, freq=None, ordinal=None, year=None, month=None, quarter=None, day=None, hour=None, minute=None, second=None)[source]#

Represents a period of time.

A Period represents a specific time span rather than a point in time. Unlike Timestamp, which represents a single instant, a Period defines a duration, such as a month, quarter, or year. The exact representation is determined by the freq parameter.

Parameters:

valuePeriod, str, datetime, date or pandas.Timestamp, default None

The time period represented (e.g., ‘4Q2005’). This represents neither the start or the end of the period, but rather the entire period itself.

freqstr, default None

One of pandas period strings or corresponding objects. Accepted strings are listed in theperiod alias section in the user docs. If value is datetime, freq is required.

ordinalint, default None

The period offset from the proleptic Gregorian epoch.

yearint, default None

Year value of the period.

monthint, default 1

Month value of the period.

quarterint, default None

Quarter value of the period.

dayint, default 1

Day value of the period.

hourint, default 0

Hour value of the period.

minuteint, default 0

Minute value of the period.

secondint, default 0

Second value of the period.

See also

Timestamp

Pandas replacement for python datetime.datetime object.

date_range

Return a fixed frequency DatetimeIndex.

timedelta_range

Generates a fixed frequency range of timedeltas.

Examples

period = pd.Period('2012-1-1', freq='D') period Period('2012-01-01', 'D')

Attributes

Methods