Skip to content

DOC: update documentation for YearBegin #52352

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 1 commit into from
Apr 3, 2023
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
20 changes: 18 additions & 2 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2313,12 +2313,28 @@ cdef class YearEnd(YearOffset):

cdef class YearBegin(YearOffset):
"""
DateOffset increments between calendar year begin dates.
DateOffset of one year at beginning.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this matches the wording on MonthBegin

wondering if there's a clearer wording, but that can be for a separate PR


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

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

Examples
--------
>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts = pd.Timestamp(2022, 12, 1)
>>> ts + pd.offsets.YearBegin()
Timestamp('2023-01-01 00:00:00')

>>> ts = pd.Timestamp(2023, 1, 1)
>>> ts + pd.offsets.YearBegin()
Timestamp('2024-01-01 00:00:00')

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

>>> ts = pd.Timestamp(2023, 1, 1)
>>> pd.offsets.YearBegin().rollback(ts)
Timestamp('2023-01-01 00:00:00')
"""

Expand Down