Series.dt
can be used to access series values as datetimelike and return multiple properties. Series.dt.dayofweek
Pandas Series.dt.dayofweek
returns the day of the week. The week is assumed to start on Monday, which is 0 and ends on Sunday, which is 6.
Syntax: Series.dt.dayofweek
Parameter: None
Returns: numpy array
Example # 1: Use the Series.dt.dayofweek
attribute to return the day of the week for a given datetime in the underlying data of this Series object.
|
Output:
We will now use the Series.dt.dayofweek
attribute to return the day of the week for a given date and time in the underlying data of this Series object .
|
Output:
As we can see from the output, the attribute is Series.dt.dayofweek
successfully accessed and returned the day of the week in the underlying data of this series object.
Example # 2: Use the Series.dt.dayofweek
attribute to return the day of the week for a given datetime in the underlying data of a given Series object.
|
Output:
Now we will use the attribute Series.dt.dayofweek
to return the day of the week for a given date and time in the underlying data of this Series object.
# print the result |
Output:
As we can see from the output, the Series.dt.dayofweek
successfully accessed and returned the day of the week in the underlying data of this series object.