Skip to content

Commit e61d371

Browse files
authored
DOC: update documentation for YearBegin (#52352)
update docs for YearBegin, add examples
1 parent 1aebbb2 commit e61d371

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
@@ -2313,12 +2313,28 @@ cdef class YearEnd(YearOffset):
23132313

23142314
cdef class YearBegin(YearOffset):
23152315
"""
2316-
DateOffset increments between calendar year begin dates.
2316+
DateOffset of one year at beginning.
2317+
2318+
YearBegin goes to the next date which is a start of the year.
2319+
2320+
See Also
2321+
--------
2322+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
23172323
23182324
Examples
23192325
--------
2320-
>>> ts = pd.Timestamp(2022, 1, 1)
2326+
>>> ts = pd.Timestamp(2022, 12, 1)
2327+
>>> ts + pd.offsets.YearBegin()
2328+
Timestamp('2023-01-01 00:00:00')
2329+
2330+
>>> ts = pd.Timestamp(2023, 1, 1)
23212331
>>> ts + pd.offsets.YearBegin()
2332+
Timestamp('2024-01-01 00:00:00')
2333+
2334+
If you want to get the start of the current year:
2335+
2336+
>>> ts = pd.Timestamp(2023, 1, 1)
2337+
>>> pd.offsets.YearBegin().rollback(ts)
23222338
Timestamp('2023-01-01 00:00:00')
23232339
"""
23242340

0 commit comments

Comments
 (0)