Python | Период панд. Is_leap_year
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas Period.is_leap_year attribute checks for the given Period object, if the year in the object is a leap year or not. It return True if the following year is a leap year else it return False
Syntax : Period.is_leap_year
Parameters : None
Return : boolean
Example #1: Use Period.is_leap_year attribute to check if the date present in the given Period object is a leap year or not.
# importing pandas as pdimport pandas as pd # Create the Period objectprd = pd.Period(freq ="H", year = 2000, month = 2, day = 21, hour = 8) # Print the Period objectprint(prd) |
Выход :
Now we will use the Period.is_leap_year attribute to check if the date present in the prd object is a leap year or not.
# check for leap yearprd.is_leap_year |
Выход :

As we can see in the output, the Period.is_leap_year attribute has returned True indicating that the following year in the prd object is a leap year.
Example #2: Use Period.is_leap_year attribute to check if the date present in the given Period object is a leap year or not.
# importing pandas as pdimport pandas as pd # Create the Period objectprd = pd.Period(freq ="T", year = 2006, month = 10, hour = 15, minute = 49) # Print the Period objectprint(prd) |
Выход :

Now we will use the Period.is_leap_year attribute to check if the date present in the prd object is a leap year or not.
# check for leap yearprd.is_leap_year |
Выход :

As we can see in the output, the Period.is_leap_year attribute has returned False indicating that the following year in the prd object is not a leap year.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.