Skip to content

Commit c826a50

Browse files
tswastmeeseeksmachine
authored andcommitted
Backport PR pandas-dev#46697: DOC: indicate that month_name and day_name also applies to Series
1 parent b49b164 commit c826a50

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
@@ -1217,7 +1217,8 @@ def to_perioddelta(self, freq) -> TimedeltaArray:
12171217

12181218
def month_name(self, locale=None):
12191219
"""
1220-
Return the month names of the DateTimeIndex with specified locale.
1220+
Return the month names of the :class:`~pandas.Series` or
1221+
:class:`~pandas.DatetimeIndex` with specified locale.
12211222
12221223
Parameters
12231224
----------
@@ -1227,11 +1228,23 @@ def month_name(self, locale=None):
12271228
12281229
Returns
12291230
-------
1230-
Index
1231-
Index of month names.
1231+
Series or Index
1232+
Series or Index of month names.
12321233
12331234
Examples
12341235
--------
1236+
>>> s = pd.Series(pd.date_range(start='2018-01', freq='M', periods=3))
1237+
>>> s
1238+
0 2018-01-31
1239+
1 2018-02-28
1240+
2 2018-03-31
1241+
dtype: datetime64[ns]
1242+
>>> s.dt.month_name()
1243+
0 January
1244+
1 February
1245+
2 March
1246+
dtype: object
1247+
12351248
>>> idx = pd.date_range(start='2018-01', freq='M', periods=3)
12361249
>>> idx
12371250
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
@@ -1247,7 +1260,8 @@ def month_name(self, locale=None):
12471260

12481261
def day_name(self, locale=None):
12491262
"""
1250-
Return the day names of the DateTimeIndex with specified locale.
1263+
Return the day names of the :class:`~pandas.Series` or
1264+
:class:`~pandas.DatetimeIndex` with specified locale.
12511265
12521266
Parameters
12531267
----------
@@ -1257,11 +1271,23 @@ def day_name(self, locale=None):
12571271
12581272
Returns
12591273
-------
1260-
Index
1261-
Index of day names.
1274+
Series or Index
1275+
Series or Index of day names.
12621276
12631277
Examples
12641278
--------
1279+
>>> s = pd.Series(pd.date_range(start='2018-01-01', freq='D', periods=3))
1280+
>>> s
1281+
0 2018-01-01
1282+
1 2018-01-02
1283+
2 2018-01-03
1284+
dtype: datetime64[ns]
1285+
>>> s.dt.day_name()
1286+
0 Monday
1287+
1 Tuesday
1288+
2 Wednesday
1289+
dtype: object
1290+
12651291
>>> idx = pd.date_range(start='2018-01-01', freq='D', periods=3)
12661292
>>> idx
12671293
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],

0 commit comments

Comments
 (0)