The is_leap_year
attribute of a Period
object in Pandas checks whether the date of the Period
is a leap year.
The is_leap_year
attribute takes the syntax below:
Period.is_leap_year
The is_leap_year
attribute takes no parameter value.
The is_leap_year
attribute returns a boolean value: True
if the year specified in the Period
object is a leap year, and False
otherwise.
# A code to illustrate the is_leap_year attribute# Importing the Pandas libraryimport pandas as pd# Creating a period objecta = pd.Period('2022-5-2')b = pd.Period('2020-5-2')# Checking if the period's year is a leap year or notprint(a.is_leap_year)print(b.is_leap_year)
pandas
library.Period
objects a
and b
with different year component values.a
or b
have values of leap years.