pandas.DatetimeIndex.day_name#
- DatetimeIndex.day_name(locale=None)[source]#
Return the day names with specified locale.
This method returns the full name of the day of the week (e.g., “Monday”, “Tuesday”) for each datetime value in the Series/Index. The names can be localized to different languages using the locale parameter.
- Parameters:
- localestr, optional
Locale determining the language in which to return the day name. Default is English locale (
'en_US.utf8'). Use the commandlocale -aon your terminal on Unix systems to find your locale language code.
- Returns:
- Index
Index of day names.
See also
DatetimeIndex.month_nameReturn the month names with specified locale.
Examples
>>> idx = pd.date_range(start="2018-01-01", freq="D", periods=3) >>> idx DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'], dtype='datetime64[us]', freq='D') >>> idx.day_name() Index(['Monday', 'Tuesday', 'Wednesday'], dtype='str')
Using the
localeparameter you can set a different locale language, for example:idx.day_name(locale='pt_BR.utf8')will return day names in Brazilian Portuguese language.>>> idx.day_name(locale="pt_BR.utf8") Index(['Segunda', 'Terça', 'Quarta'], dtype='str')