Skip to content

Commit ba6a072

Browse files
Pequejreback
authored andcommitted
DOC: Update month_name and day_name docstrings (#22544)
1 parent 5eb9988 commit ba6a072

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

pandas/core/arrays/datetimes.py

+30-10
Original file line numberDiff line numberDiff line change
@@ -771,17 +771,27 @@ def month_name(self, locale=None):
771771
"""
772772
Return the month names of the DateTimeIndex with specified locale.
773773
774+
.. versionadded:: 0.23.0
775+
774776
Parameters
775777
----------
776-
locale : string, default None (English locale)
777-
locale determining the language in which to return the month name
778+
locale : str, optional
779+
Locale determining the language in which to return the month name.
780+
Default is English locale.
778781
779782
Returns
780783
-------
781-
month_names : Index
782-
Index of month names
784+
Index
785+
Index of month names.
783786
784-
.. versionadded:: 0.23.0
787+
Examples
788+
--------
789+
>>> idx = pd.DatetimeIndex(start='2018-01', freq='M', periods=3)
790+
>>> idx
791+
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
792+
dtype='datetime64[ns]', freq='M')
793+
>>> idx.month_name()
794+
Index(['January', 'February', 'March'], dtype='object')
785795
"""
786796
if self.tz is not None and self.tz is not utc:
787797
values = self._local_timestamps()
@@ -797,17 +807,27 @@ def day_name(self, locale=None):
797807
"""
798808
Return the day names of the DateTimeIndex with specified locale.
799809
810+
.. versionadded:: 0.23.0
811+
800812
Parameters
801813
----------
802-
locale : string, default None (English locale)
803-
locale determining the language in which to return the day name
814+
locale : str, optional
815+
Locale determining the language in which to return the day name.
816+
Default is English locale.
804817
805818
Returns
806819
-------
807-
month_names : Index
808-
Index of day names
820+
Index
821+
Index of day names.
809822
810-
.. versionadded:: 0.23.0
823+
Examples
824+
--------
825+
>>> idx = pd.DatetimeIndex(start='2018-01-01', freq='D', periods=3)
826+
>>> idx
827+
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
828+
dtype='datetime64[ns]', freq='D')
829+
>>> idx.day_name()
830+
Index(['Monday', 'Tuesday', 'Wednesday'], dtype='object')
811831
"""
812832
if self.tz is not None and self.tz is not utc:
813833
values = self._local_timestamps()

0 commit comments

Comments
 (0)