What is the pandas.Period.day attribute in pandas?
Overview
The Period.day attribute in pandas is used to obtain the particular day of the month that a Period object falls on. A Period object here represents a period of time.
Syntax
The Period.day attribute has the following syntax:
Period.day
Syntax for the Period.day attribute
Parameter value
Because Period.day is an attribute, it does not take any parameter values.
Return value
The Period.day attribute returns an int that indicates the day of the month for that period.
Example
# A code to illustrate the Period.day attribute in Pandas# importing the pandas libraryimport pandas as pd# creating a perioda = pd.Period("2022-05-01")print(a.day)
Explanation
- Line 4: We import the
pandaslibrary. - Line 7: We create a
Periodobjecta. - Line 9: We obtain the day from the
Periodobject using the attributePeriod.day, and print the value to the console.