Skip to content

Commit 9d72428

Browse files
CalmDownKarmPingviinituutti
authored andcommitted
DOC: update the is_month_start/is_month_end docstring (pandas-dev#23051)
1 parent 8fa5a7c commit 9d72428

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

pandas/core/arrays/datetimes.py

+30-18
Original file line numberDiff line numberDiff line change
@@ -1046,48 +1046,60 @@ def date(self):
10461046
'dim',
10471047
"The number of days in the month")
10481048
daysinmonth = days_in_month
1049-
is_month_start = _field_accessor(
1050-
'is_month_start',
1051-
'is_month_start',
1052-
"Logical indicating if first day of month (defined by frequency)")
1053-
is_month_end = _field_accessor(
1054-
'is_month_end',
1055-
'is_month_end',
1056-
"""
1057-
Indicator for whether the date is the last day of the month.
1049+
_is_month_doc = """
1050+
Indicates whether the date is the {first_or_last} day of the month.
10581051
10591052
Returns
10601053
-------
10611054
Series or array
1062-
For Series, returns a Series with boolean values. For
1063-
DatetimeIndex, returns a boolean array.
1055+
For Series, returns a Series with boolean values.
1056+
For DatetimeIndex, returns a boolean array.
10641057
10651058
See Also
10661059
--------
1067-
is_month_start : Indicator for whether the date is the first day
1068-
of the month.
1060+
is_month_start : Return a boolean indicating whether the date
1061+
is the first day of the month.
1062+
is_month_end : Return a boolean indicating whether the date
1063+
is the last day of the month.
10691064
10701065
Examples
10711066
--------
10721067
This method is available on Series with datetime values under
10731068
the ``.dt`` accessor, and directly on DatetimeIndex.
10741069
1075-
>>> dates = pd.Series(pd.date_range("2018-02-27", periods=3))
1076-
>>> dates
1070+
>>> s = pd.Series(pd.date_range("2018-02-27", periods=3))
1071+
>>> s
10771072
0 2018-02-27
10781073
1 2018-02-28
10791074
2 2018-03-01
10801075
dtype: datetime64[ns]
1081-
>>> dates.dt.is_month_end
1076+
>>> s.dt.is_month_start
1077+
0 False
1078+
1 False
1079+
2 True
1080+
dtype: bool
1081+
>>> s.dt.is_month_end
10821082
0 False
10831083
1 True
10841084
2 False
10851085
dtype: bool
10861086
10871087
>>> idx = pd.date_range("2018-02-27", periods=3)
1088+
>>> idx.is_month_start
1089+
array([False, False, True])
10881090
>>> idx.is_month_end
1089-
array([False, True, False], dtype=bool)
1090-
""")
1091+
array([False, True, False])
1092+
"""
1093+
is_month_start = _field_accessor(
1094+
'is_month_start',
1095+
'is_month_start',
1096+
_is_month_doc.format(first_or_last='first'))
1097+
1098+
is_month_end = _field_accessor(
1099+
'is_month_end',
1100+
'is_month_end',
1101+
_is_month_doc.format(first_or_last='last'))
1102+
10911103
is_quarter_start = _field_accessor(
10921104
'is_quarter_start',
10931105
'is_quarter_start',

0 commit comments

Comments
 (0)