Python | Pandas Timestamp.daysinmonth
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas Timestamp.daysinmonth attribute return the number of days in the month for the given date in the Timestamp object.
Syntax : Timestamp.daysinmonth
Parameters : None
Return : number of days in month
Example #1: Use Timestamp.daysinmonth attribute to find out the number of days in the given Timestamp object.
# importing pandas as pdimport pandas as pd # Create the Timestamp objectts = pd.Timestamp(2017, 2, 15, 12) # Print the Timestamp objectprint(ts) |
Выход :

Now we will use the Timestamp.daysinmonth attribute to find out the number of days in the given Timestamp object.
# return the number of days in monthts.daysinmonth |
Выход :

As we can see in the output, the Timestamp.daysinmonth attribute has returned 28 indicating that there are 28 days in the month of the given Timestamp object.
Example #2: Use Timestamp.daysinmonth attribute to find out the number of days in the given Timestamp object.
# importing pandas as pdimport pandas as pd # Create the Timestamp objectts = pd.Timestamp(year = 2009, month = 10, day = 21, tz = "Europe/Berlin") # Print the Timestamp objectprint(ts) |
Выход :

Now we will use the Timestamp.daysinmonth attribute to find out the number of days in the given Timestamp object.
# return the number of days in monthts.daysinmonth |
Выход :

As we can see in the output, the Timestamp.daysinmonth attribute has returned 31 indicating that there are 31 days in the month of the given Timestamp object.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.