Skip to content

DOC: update the pandas.DateTimeArrayMixin.is_month_start docstring #23051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
58 changes: 36 additions & 22 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,48 +998,62 @@ def date(self):
'dim',
"The number of days in the month")
daysinmonth = days_in_month
is_month_start = _field_accessor(
'is_month_start',
'is_month_start',
"Logical indicating if first day of month (defined by frequency)")
is_month_end = _field_accessor(
'is_month_end',
'is_month_end',
"""
Indicator for whether the date is the last day of the month.
_is_month_doc = """
Indicates whether the date is the {first_or_last} day of the month.

Returns
-------
Series or array
For Series, returns a Series with boolean values. For
DatetimeIndex, returns a boolean array.
For Series, returns a Series with bool.
For DatetimeIndex, returns a bool array.

See Also
--------
is_month_start : Indicator for whether the date is the first day
of the month.
is_month_{end_or_start} : Return a boolean indicating whether the date
is the {last_or_first} day of the month.

Examples
--------
This method is available on Series with datetime values under
the ``.dt`` accessor, and directly on DatetimeIndex.

>>> dates = pd.Series(pd.date_range("2018-02-27", periods=3))
>>> dates
>>> s = pd.Series(pd.date_range("2018-02-27", periods=3))
>>> s
0 2018-02-27
1 2018-02-28
2 2018-03-01
dtype: datetime64[ns]
>>> dates.dt.is_month_end
0 False
1 True
2 False
>>> s.dt.is_month_{start_or_end}
0 {FT[0]}
1 {FT[1]}
2 {FT[2]}
dtype: bool

>>> idx = pd.date_range("2018-02-27", periods=3)
>>> idx.is_month_end
array([False, True, False], dtype=bool)
""")
>>> idx.is_month_{start_or_end}
array([{FT[3]}, {FT[4]}, {FT[5]}])
"""
is_month_start = _field_accessor(
'is_month_start',
'is_month_start',
_is_month_doc.format(
first_or_last='first',
start_or_end='start',
FT=[False, False, True, False, False, True],
end_or_start='end',
last_or_first='last'
))

is_month_end = _field_accessor(
'is_month_end',
'is_month_end',
_is_month_doc.format(
first_or_last='last',
start_or_end='end',
FT=[False, True, False, False, True, False],
end_or_start='start',
last_or_first='first'
))
is_quarter_start = _field_accessor(
'is_quarter_start',
'is_quarter_start',
Expand Down