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

Now we will use the Period.dayofweek attribute to find the day of the week in the given object.
# return the day value prd.dayofweek |
Выход :

As we can see in the output, the Period.dayofweek attribute has returned 6 indicating that the following date was the 6th day of the week.
Example #2: Use Period.dayofweek attribute to find the day of the week in the given Period object.
Выход :

Now we will use the Period.dayofweek attribute to find the day of the week in the given object.
# return the day value prd.dayofweek |
Выход :
As we can see in the output, the Period.dayofweek attribute has returned 4 indicating that the following date was the 4th day of the week.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.