Skip to content

Commit 471dcd1

Browse files
natmokvalim-vinicius
authored and
im-vinicius
committed
DOC: add examples to offsets.YearEnd (pandas-dev#52942)
add examples to offsets.YearEnd
1 parent d0e2524 commit 471dcd1

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

pandas/_libs/tslibs/offsets.pyx

+19-3
Original file line numberDiff line numberDiff line change
@@ -2291,13 +2291,29 @@ cdef class BYearBegin(YearOffset):
22912291

22922292
cdef class YearEnd(YearOffset):
22932293
"""
2294-
DateOffset increments between calendar year ends.
2294+
DateOffset increments between calendar year end dates.
2295+
2296+
YearEnd goes to the next date which is the end of the year.
2297+
2298+
See Also
2299+
--------
2300+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
22952301
22962302
Examples
22972303
--------
22982304
>>> ts = pd.Timestamp(2022, 1, 1)
22992305
>>> ts + pd.offsets.YearEnd()
23002306
Timestamp('2022-12-31 00:00:00')
2307+
2308+
>>> ts = pd.Timestamp(2022, 12, 31)
2309+
>>> ts + pd.offsets.YearEnd()
2310+
Timestamp('2023-12-31 00:00:00')
2311+
2312+
If you want to get the end of the current year:
2313+
2314+
>>> ts = pd.Timestamp(2022, 12, 31)
2315+
>>> pd.offsets.YearEnd().rollback(ts)
2316+
Timestamp('2022-12-31 00:00:00')
23012317
"""
23022318

23032319
_default_month = 12
@@ -2316,9 +2332,9 @@ cdef class YearEnd(YearOffset):
23162332

23172333
cdef class YearBegin(YearOffset):
23182334
"""
2319-
DateOffset of one year at beginning.
2335+
DateOffset increments between calendar year begin dates.
23202336
2321-
YearBegin goes to the next date which is a start of the year.
2337+
YearBegin goes to the next date which is the start of the year.
23222338
23232339
See Also
23242340
--------

0 commit comments

Comments
 (0)