Skip to content

Commit fae47ff

Browse files
DOC: Additions to month_name & day_name (pandas-dev#51154)
* DOC: Additions to month_name & day_name * FIX: Removing whitespaces * doctest +SKIP: because of unavailable locale * specifying the OS in which the command locale -a works
1 parent bd4ece5 commit fae47ff

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

pandas/core/arrays/datetimes.py

+28-2
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,9 @@ def month_name(self, locale=None) -> npt.NDArray[np.object_]:
12021202
----------
12031203
locale : str, optional
12041204
Locale determining the language in which to return the month name.
1205-
Default is English locale.
1205+
Default is English locale (``'en_US.utf8'``). Use the command
1206+
``locale -a`` on your terminal on Unix systems to find your locale
1207+
language code.
12061208
12071209
Returns
12081210
-------
@@ -1229,6 +1231,17 @@ def month_name(self, locale=None) -> npt.NDArray[np.object_]:
12291231
dtype='datetime64[ns]', freq='M')
12301232
>>> idx.month_name()
12311233
Index(['January', 'February', 'March'], dtype='object')
1234+
1235+
Using the ``locale`` parameter you can set a different locale language,
1236+
for example: ``idx.month_name(locale='pt_BR.utf8')`` will return month
1237+
names in Brazilian Portuguese language.
1238+
1239+
>>> idx = pd.date_range(start='2018-01', freq='M', periods=3)
1240+
>>> idx
1241+
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
1242+
dtype='datetime64[ns]', freq='M')
1243+
>>> idx.month_name(locale='pt_BR.utf8') # doctest: +SKIP
1244+
Index(['Janeiro', 'Fevereiro', 'Março'], dtype='object')
12321245
"""
12331246
values = self._local_timestamps()
12341247

@@ -1246,7 +1259,9 @@ def day_name(self, locale=None) -> npt.NDArray[np.object_]:
12461259
----------
12471260
locale : str, optional
12481261
Locale determining the language in which to return the day name.
1249-
Default is English locale.
1262+
Default is English locale (``'en_US.utf8'``). Use the command
1263+
``locale -a`` on your terminal on Unix systems to find your locale
1264+
language code.
12501265
12511266
Returns
12521267
-------
@@ -1273,6 +1288,17 @@ def day_name(self, locale=None) -> npt.NDArray[np.object_]:
12731288
dtype='datetime64[ns]', freq='D')
12741289
>>> idx.day_name()
12751290
Index(['Monday', 'Tuesday', 'Wednesday'], dtype='object')
1291+
1292+
Using the ``locale`` parameter you can set a different locale language,
1293+
for example: ``idx.day_name(locale='pt_BR.utf8')`` will return day
1294+
names in Brazilian Portuguese language.
1295+
1296+
>>> idx = pd.date_range(start='2018-01-01', freq='D', periods=3)
1297+
>>> idx
1298+
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
1299+
dtype='datetime64[ns]', freq='D')
1300+
>>> idx.day_name(locale='pt_BR.utf8') # doctest: +SKIP
1301+
Index(['Segunda', 'Terça', 'Quarta'], dtype='object')
12761302
"""
12771303
values = self._local_timestamps()
12781304

0 commit comments

Comments
 (0)