Python | Pandas Period.is_leap_year

Python | Pandas Period.is_leap_year

The pandas.Period object represents a time period. It has a property called is_leap_year which you can use to determine if the year of the period is a leap year.

Here's how you can use the is_leap_year property:

import pandas as pd # Create a Period for a specific year p = pd.Period('2020') # Check if it's a leap year print(p.is_leap_year) # Output: True # Another example p2 = pd.Period('2019') print(p2.is_leap_year) # Output: False 

In this example, 2020 is a leap year, so the first print statement outputs True. 2019 is not a leap year, so the second print statement outputs False.


More Tags

hashtable user-defined-functions spring-repositories text-formatting material-ui spline terminology mtu collections resampling

More Programming Guides

Other Guides

More Programming Examples