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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merged is_month_start and is_month_end docstrings
  • Loading branch information
karmanya.aggarwal committed Oct 20, 2018
commit 781a3b92c4181ecd4aa0f755ff50657763fd74cc
79 changes: 32 additions & 47 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,77 +998,62 @@ def date(self):
'dim',
"The number of days in the month")
daysinmonth = days_in_month
_is_month_start_doc = """
Indicates whether the date is the first day of the month.
_is_month_doc = """
Indicates whether the date is the {first_or_last} day of the month.

Returns
-------
Series of bool
Series of boolean values indicating whether the date is the first
day of the month.
Series or array
For Series, returns a Series with bool.
For DatetimeIndex, returns a bool array.

See Also
--------
is_month_end : Return a boolean indicating whether the date is
the last 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.

>>> 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]
>>> s.dt.is_month_start
0 False
1 False
2 True
>>> 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_{start_or_end}
array([{FT[3]}, {FT[4]}, {FT[5]}])
"""
is_month_start = _field_accessor(
'is_month_start',
'is_month_start',
_is_month_start_doc)
_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',
"""
Indicator for whether the date is the last day of the month.

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

See Also
--------
is_month_start : Indicator for whether the date is the 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
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
dtype: bool

>>> idx = pd.date_range("2018-02-27", periods=3)
>>> idx.is_month_end
array([False, True, False], dtype=bool)
""")
_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