w3resource

Pandas Series property: dt.weekday

Series.dt.weekday property

The weekday property is used get the day of the week of a given date.

The day of the week with Monday=0, Sunday=6.

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 or DatetimeIndex.

Syntax:

Series.dt.weekday
Pandas Series: dt.weekday property

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: Series.dt.dayofweek property
Next: Series.dt.is_month_start property



Become a Patron!

Follow us on Facebook and Twitter for latest update.

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://w3resource.com/pandas/series/series-dt-weekday.php