Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,8 @@ def to_perioddelta(self, freq) -> TimedeltaArray:

def month_name(self, locale=None):
"""
Return the month names of the DateTimeIndex with specified locale.
Return the month names of the :class:`~pandas.Series` or
:class:`~pandas.DatetimeIndex` with specified locale.

Parameters
----------
Expand All @@ -1239,11 +1240,23 @@ def month_name(self, locale=None):

Returns
-------
Index
Index of month names.
Series or Index
Series or Index of month names.

Examples
--------
>>> s = pd.Series(pd.date_range(start='2018-01', freq='M', periods=3))
>>> s
0 2018-01-31
1 2018-02-28
2 2018-03-31
dtype: datetime64[ns]
>>> s.dt.month_name()
0 January
1 February
2 March
dtype: object

>>> idx = pd.date_range(start='2018-01', freq='M', periods=3)
>>> idx
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
Expand All @@ -1259,7 +1272,8 @@ def month_name(self, locale=None):

def day_name(self, locale=None):
"""
Return the day names of the DateTimeIndex with specified locale.
Return the day names of the :class:`~pandas.Series` or
:class:`~pandas.DatetimeIndex` with specified locale.

Parameters
----------
Expand All @@ -1269,11 +1283,23 @@ def day_name(self, locale=None):

Returns
-------
Index
Index of day names.
Series or Index
Series or Index of day names.

Examples
--------
>>> s = pd.Series(pd.date_range(start='2018-01-01', freq='D', periods=3))
>>> s
0 2018-01-01
1 2018-01-02
2 2018-01-03
dtype: datetime64[ns]
>>> s.dt.day_name()
0 Monday
1 Tuesday
2 Wednesday
dtype: object

>>> idx = pd.date_range(start='2018-01-01', freq='D', periods=3)
>>> idx
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
Expand Down