pandas.Period

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

Represents a period of time.

Parameters
valuePeriod or str, 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 the offset alias section in the user docs.

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.

Examples

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

Attributes

day

Get day of the month that a Period falls on.

day_of_week

Day of the week the period lies in, with Monday=0 and Sunday=6.

day_of_year

Return the day of the year.

dayofweek

Day of the week the period lies in, with Monday=0 and Sunday=6.

dayofyear

Return the day of the year.

days_in_month

Get the total number of days in the month that this period falls on.

daysinmonth

Get the total number of days of the month that this period falls on.

end_time

Get the Timestamp for the end of the period.

freqstr

Return a string representation of the frequency.

hour

Get the hour of the day component of the Period.

is_leap_year

Return True if the period's year is in a leap year.

minute

Get minute of the hour component of the Period.

month

Return the month this Period falls on.

quarter

Return the quarter this Period falls on.

qyear

Fiscal year the Period lies in according to its starting-quarter.

second

Get the second component of the Period.

start_time

Get the Timestamp for the start of the period.

week

Get the week of the year on the given Period.

weekday

Day of the week the period lies in, with Monday=0 and Sunday=6.

weekofyear

Get the week of the year on the given Period.

year

Return the year this Period falls on.

freq

ordinal

Methods

asfreq

Convert Period to desired frequency, at the start or end of the interval.

now

Return the period of now's date.

strftime

Returns a formatted string representation of the Period.

to_timestamp

Return the Timestamp representation of the Period.