Skip to content

Commit ffadd9f

Browse files
Backport PR pandas-dev#52352 on branch 2.0.x (DOC: update documentation for YearBegin) (pandas-dev#52374)
Backport PR pandas-dev#52352: DOC: update documentation for YearBegin Co-authored-by: Natalia Mokeeva <[email protected]>
1 parent 940b80d commit ffadd9f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

pandas/_libs/tslibs/offsets.pyx

+18-2
Original file line numberDiff line numberDiff line change
@@ -2310,13 +2310,29 @@ cdef class YearEnd(YearOffset):
23102310

23112311
cdef class YearBegin(YearOffset):
23122312
"""
2313-
DateOffset increments between calendar year begin dates.
2313+
DateOffset of one year at beginning.
2314+
2315+
YearBegin goes to the next date which is a start of the year.
2316+
2317+
See Also
2318+
--------
2319+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
23142320
23152321
Examples
23162322
--------
2317-
>>> ts = pd.Timestamp(2022, 1, 1)
2323+
>>> ts = pd.Timestamp(2022, 12, 1)
23182324
>>> ts + pd.offsets.YearBegin()
23192325
Timestamp('2023-01-01 00:00:00')
2326+
2327+
>>> ts = pd.Timestamp(2023, 1, 1)
2328+
>>> ts + pd.offsets.YearBegin()
2329+
Timestamp('2024-01-01 00:00:00')
2330+
2331+
If you want to get the start of the current year:
2332+
2333+
>>> ts = pd.Timestamp(2023, 1, 1)
2334+
>>> pd.offsets.YearBegin().rollback(ts)
2335+
Timestamp('2023-01-01 00:00:00')
23202336
"""
23212337

23222338
_default_month = 1

0 commit comments

Comments
 (0)