Python | Период панд. Дни в месяц
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas Period.daysinmonth attribute returns the number of days in the month present in the given Period object.
Syntax : Period.daysinmonth
Parameters : None
Return : number of days
Example #1: Use Period.daysinmonth attribute to find the number of days present in the month in the given Period object.
# importing pandas as pdimport pandas as pd # Create the Period objectprd = pd.Period(freq ="D", year = 2001, month = 2, day = 21) # Print the Period objectprint(prd) |
Выход :

Now we will use the Period.daysinmonth attribute to find the number of days present in the month represented in the given period object.
# return the number of daysprd.daysinmonth |
Выход :

As we can see in the output, the Period.daysinmonth attribute has returned 28 indicating that the month represented in the given period object has 28 days.
Example #2: Use Period.daysinmonth attribute to find the number of days present in the month in the given Period object.
Выход :

Now we will use the Period.daysinmonth attribute to find the number of days present in the month represented in the given period object.
# return the number of daysprd.daysinmonth |
Выход :
As we can see in the output, the Period.daysinmonth attribute has returned 31 indicating that the month represented in the given period object has 31 days.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.