Skip to content

Commit 937ff6b

Browse files
committed
DOC: Update month_name and day_name docstrings
- To fix confusing `month_index` return name in `day_name` method - To better match the preferred docstring style.
1 parent 6b83df9 commit 937ff6b

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

pandas/core/arrays/datetimes.py

+24-10
Original file line numberDiff line numberDiff line change
@@ -793,17 +793,24 @@ def month_name(self, locale=None):
793793
"""
794794
Return the month names of the DateTimeIndex with specified locale.
795795
796+
.. versionadded:: 0.23.0
797+
796798
Parameters
797799
----------
798-
locale : string, default None (English locale)
799-
locale determining the language in which to return the month name
800+
locale : str, optional
801+
Locale determining the language in which to return the month name.
802+
Default is English locale.
800803
801804
Returns
802805
-------
803-
month_names : Index
804-
Index of month names
806+
Index
807+
Index of month names.
805808
806-
.. versionadded:: 0.23.0
809+
Examples
810+
--------
811+
>>> idx = pd.DatetimeIndex(start='2018-09', freq='M', periods=3)
812+
>>> idx.month_name()
813+
Index(['September', 'October', 'November'], dtype='object')
807814
"""
808815
if self.tz is not None and self.tz is not utc:
809816
values = self._local_timestamps()
@@ -819,17 +826,24 @@ def day_name(self, locale=None):
819826
"""
820827
Return the day names of the DateTimeIndex with specified locale.
821828
829+
.. versionadded:: 0.23.0
830+
822831
Parameters
823832
----------
824-
locale : string, default None (English locale)
825-
locale determining the language in which to return the day name
833+
locale : str, optional
834+
Locale determining the language in which to return the day name.
835+
Default is English locale.
826836
827837
Returns
828838
-------
829-
month_names : Index
830-
Index of day names
839+
Index
840+
Index of day names.
831841
832-
.. versionadded:: 0.23.0
842+
Examples
843+
--------
844+
>>> idx = pd.DatetimeIndex(start='2018-09-02', freq='D', periods=3)
845+
>>> idx.day_name()
846+
Index(['Sunday', 'Monday', 'Tuesday'], dtype='object')
833847
"""
834848
if self.tz is not None and self.tz is not utc:
835849
values = self._local_timestamps()

0 commit comments

Comments
 (0)