Skip to content

Commit 4d92fc6

Browse files
tswastyehoshuadimarsky
authored andcommitted
DOC: indicate that month_name and day_name also applies to Series (pandas-dev#46697)
1 parent f3a60e6 commit 4d92fc6

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

pandas/core/arrays/datetimes.py

+32-6
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,8 @@ def to_perioddelta(self, freq) -> TimedeltaArray:
12291229

12301230
def month_name(self, locale=None):
12311231
"""
1232-
Return the month names of the DateTimeIndex with specified locale.
1232+
Return the month names of the :class:`~pandas.Series` or
1233+
:class:`~pandas.DatetimeIndex` with specified locale.
12331234
12341235
Parameters
12351236
----------
@@ -1239,11 +1240,23 @@ def month_name(self, locale=None):
12391240
12401241
Returns
12411242
-------
1242-
Index
1243-
Index of month names.
1243+
Series or Index
1244+
Series or Index of month names.
12441245
12451246
Examples
12461247
--------
1248+
>>> s = pd.Series(pd.date_range(start='2018-01', freq='M', periods=3))
1249+
>>> s
1250+
0 2018-01-31
1251+
1 2018-02-28
1252+
2 2018-03-31
1253+
dtype: datetime64[ns]
1254+
>>> s.dt.month_name()
1255+
0 January
1256+
1 February
1257+
2 March
1258+
dtype: object
1259+
12471260
>>> idx = pd.date_range(start='2018-01', freq='M', periods=3)
12481261
>>> idx
12491262
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
@@ -1259,7 +1272,8 @@ def month_name(self, locale=None):
12591272

12601273
def day_name(self, locale=None):
12611274
"""
1262-
Return the day names of the DateTimeIndex with specified locale.
1275+
Return the day names of the :class:`~pandas.Series` or
1276+
:class:`~pandas.DatetimeIndex` with specified locale.
12631277
12641278
Parameters
12651279
----------
@@ -1269,11 +1283,23 @@ def day_name(self, locale=None):
12691283
12701284
Returns
12711285
-------
1272-
Index
1273-
Index of day names.
1286+
Series or Index
1287+
Series or Index of day names.
12741288
12751289
Examples
12761290
--------
1291+
>>> s = pd.Series(pd.date_range(start='2018-01-01', freq='D', periods=3))
1292+
>>> s
1293+
0 2018-01-01
1294+
1 2018-01-02
1295+
2 2018-01-03
1296+
dtype: datetime64[ns]
1297+
>>> s.dt.day_name()
1298+
0 Monday
1299+
1 Tuesday
1300+
2 Wednesday
1301+
dtype: object
1302+
12771303
>>> idx = pd.date_range(start='2018-01-01', freq='D', periods=3)
12781304
>>> idx
12791305
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],

0 commit comments

Comments
 (0)