Skip to content
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

DOC: add missing parameters to offsets classes: BYearBegin, YearEnd, YearBegin #53280

Merged
Changes from all commits
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
49 changes: 47 additions & 2 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2251,9 +2251,13 @@ cdef class BYearEnd(YearOffset):
The number of years represented.
normalize : bool, default False
Normalize start/end dates to midnight before generating date range.
month : int, default 1
month : int, default 12
A specific integer for the month of the year.

See Also
--------
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.

Examples
--------
>>> from pandas.tseries.offsets import BYearEnd
Expand All @@ -2280,6 +2284,19 @@ cdef class BYearBegin(YearOffset):
"""
DateOffset increments between the first business day of the year.

Parameters
----------
n : int, default 1
The number of years represented.
normalize : bool, default False
Normalize start/end dates to midnight before generating date range.
month : int, default 1
A specific integer for the month of the year.

See Also
--------
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.

Examples
--------
>>> from pandas.tseries.offsets import BYearBegin
Expand All @@ -2292,6 +2309,8 @@ cdef class BYearBegin(YearOffset):
Timestamp('2020-01-01 05:01:15')
>>> ts + BYearBegin(2)
Timestamp('2022-01-03 05:01:15')
>>> ts + BYearBegin(month=11)
Timestamp('2020-11-02 05:01:15')
"""

_outputName = "BusinessYearBegin"
Expand All @@ -2306,6 +2325,15 @@ cdef class YearEnd(YearOffset):

YearEnd goes to the next date which is the end of the year.

Parameters
----------
n : int, default 1
The number of years represented.
normalize : bool, default False
Normalize start/end dates to midnight before generating date range.
month : int, default 12
A specific integer for the month of the year.

See Also
--------
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
Expand All @@ -2320,10 +2348,14 @@ cdef class YearEnd(YearOffset):
>>> ts + pd.offsets.YearEnd()
Timestamp('2023-12-31 00:00:00')

>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.YearEnd(month=2)
Timestamp('2022-02-28 00:00:00')

If you want to get the end of the current year:

>>> ts = pd.Timestamp(2022, 12, 31)
>>> pd.offsets.YearEnd().rollback(ts)
>>> pd.offsets.YearEnd().rollforward(ts)
Timestamp('2022-12-31 00:00:00')
"""

Expand All @@ -2347,6 +2379,15 @@ cdef class YearBegin(YearOffset):

YearBegin goes to the next date which is the start of the year.

Parameters
----------
n : int, default 1
The number of years represented.
normalize : bool, default False
Normalize start/end dates to midnight before generating date range.
month : int, default 1
A specific integer for the month of the year.

See Also
--------
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
Expand All @@ -2361,6 +2402,10 @@ cdef class YearBegin(YearOffset):
>>> ts + pd.offsets.YearBegin()
Timestamp('2024-01-01 00:00:00')

>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.YearBegin(month=2)
Timestamp('2022-02-01 00:00:00')

If you want to get the start of the current year:

>>> ts = pd.Timestamp(2023, 1, 1)
Expand Down