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 library
import pandas as pd
# creating a period
a = pd.Period("2022-05-01")
print(a.day)

Explanation

  • Line 4: We import the pandas library.
  • Line 7: We create a Period object a.
  • Line 9: We obtain the day from the Period object using the attribute Period.day, and print the value to the console.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources