Pandas Series property: dt.dayofweek
Series.dt.dayofweek property
The dayofweek property is used to get the day of the week.
The day of the week with Monday=0, Sunday=6.
Note: It is assumed the week starts on Monday, which is denoted by 0 and ends on Sunday which is denoted by 6. This method is available on both Series with datetime values (using the dt accessor) or DatetimeIndex.
Syntax:
Series.dt.dayofweek
Returns: Series or Index
Containing integers indicating the day number.
Example:
Python-Pandas Code:
import numpy as np
import pandas as pd
s = pd.date_range('2018-12-31', '2019-01-08', freq='D').to_series()
s.dt.dayofweek
Output:
2018-12-31 0 2019-01-01 1 2019-01-02 2 2019-01-03 3 2019-01-04 4 2019-01-05 5 2019-01-06 6 2019-01-07 0 2019-01-08 1 Freq: D, dtype: int64
Previous: Select values between particular times of the day
Next: Series.dt.weekday property
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/pandas/series/series-dt-dayofweek.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics