diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index b1c19ab7c0476..9c9faa0a343db 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -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 ---------- @@ -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'], @@ -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 ---------- @@ -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'],