Pandas Series: dt.day_name() function
Series.dt.day_name() function
The dt.day_name() function is used to get the day names of the DateTimeIndex with specified locale.
Syntax:
Series.dt.day_name(self, *args, **kwargs)
Parameter:
Name | Description | Type / Default Value | Required / Optional |
---|---|---|---|
locale | Locale determining the language in which to return the day name. Default is English locale. | str | Optional |
Returns: Index
Index of day names.
Example:
Python-Pandas Code:
import numpy as np
import pandas as pd
idx = pd.date_range(start='2019-02-01', freq='D', periods=4)
idx
Output:
DatetimeIndex(['2019-02-01', '2019-02-02', '2019-02-03', '2019-02-04'], dtype='datetime64[ns]', freq='D')
Python-Pandas Code:
import numpy as np
import pandas as pd
idx = pd.date_range(start='2019-02-01', freq='D', periods=4)
idx.day_name()
Output:
Index(['Friday', 'Saturday', 'Sunday', 'Monday'], dtype='object')
Previous: Series.dt.month_name() function
Next: Series-dt.components() function
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-day_name.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics