Skip to content

Commit 9116a2b

Browse files
natmokvalMarcoGorelli
authored and
im-vinicius
committed
DOC: add missing parameters to offsets classes: BYearBegin, YearEnd, YearBegin (pandas-dev#53280)
* DOC: add missing parameters to offsets classes: BYearBegin, YearEnd, YearBegin * update "get to the end of the year" suggestion to use rollforward instead of rollback --------- Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent d12196c commit 9116a2b

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

pandas/_libs/tslibs/offsets.pyx

+47-2
Original file line numberDiff line numberDiff line change
@@ -2251,9 +2251,13 @@ cdef class BYearEnd(YearOffset):
22512251
The number of years represented.
22522252
normalize : bool, default False
22532253
Normalize start/end dates to midnight before generating date range.
2254-
month : int, default 1
2254+
month : int, default 12
22552255
A specific integer for the month of the year.
22562256
2257+
See Also
2258+
--------
2259+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
2260+
22572261
Examples
22582262
--------
22592263
>>> from pandas.tseries.offsets import BYearEnd
@@ -2280,6 +2284,19 @@ cdef class BYearBegin(YearOffset):
22802284
"""
22812285
DateOffset increments between the first business day of the year.
22822286
2287+
Parameters
2288+
----------
2289+
n : int, default 1
2290+
The number of years represented.
2291+
normalize : bool, default False
2292+
Normalize start/end dates to midnight before generating date range.
2293+
month : int, default 1
2294+
A specific integer for the month of the year.
2295+
2296+
See Also
2297+
--------
2298+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
2299+
22832300
Examples
22842301
--------
22852302
>>> from pandas.tseries.offsets import BYearBegin
@@ -2292,6 +2309,8 @@ cdef class BYearBegin(YearOffset):
22922309
Timestamp('2020-01-01 05:01:15')
22932310
>>> ts + BYearBegin(2)
22942311
Timestamp('2022-01-03 05:01:15')
2312+
>>> ts + BYearBegin(month=11)
2313+
Timestamp('2020-11-02 05:01:15')
22952314
"""
22962315

22972316
_outputName = "BusinessYearBegin"
@@ -2306,6 +2325,15 @@ cdef class YearEnd(YearOffset):
23062325
23072326
YearEnd goes to the next date which is the end of the year.
23082327
2328+
Parameters
2329+
----------
2330+
n : int, default 1
2331+
The number of years represented.
2332+
normalize : bool, default False
2333+
Normalize start/end dates to midnight before generating date range.
2334+
month : int, default 12
2335+
A specific integer for the month of the year.
2336+
23092337
See Also
23102338
--------
23112339
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
@@ -2320,10 +2348,14 @@ cdef class YearEnd(YearOffset):
23202348
>>> ts + pd.offsets.YearEnd()
23212349
Timestamp('2023-12-31 00:00:00')
23222350
2351+
>>> ts = pd.Timestamp(2022, 1, 1)
2352+
>>> ts + pd.offsets.YearEnd(month=2)
2353+
Timestamp('2022-02-28 00:00:00')
2354+
23232355
If you want to get the end of the current year:
23242356
23252357
>>> ts = pd.Timestamp(2022, 12, 31)
2326-
>>> pd.offsets.YearEnd().rollback(ts)
2358+
>>> pd.offsets.YearEnd().rollforward(ts)
23272359
Timestamp('2022-12-31 00:00:00')
23282360
"""
23292361

@@ -2347,6 +2379,15 @@ cdef class YearBegin(YearOffset):
23472379
23482380
YearBegin goes to the next date which is the start of the year.
23492381
2382+
Parameters
2383+
----------
2384+
n : int, default 1
2385+
The number of years represented.
2386+
normalize : bool, default False
2387+
Normalize start/end dates to midnight before generating date range.
2388+
month : int, default 1
2389+
A specific integer for the month of the year.
2390+
23502391
See Also
23512392
--------
23522393
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
@@ -2361,6 +2402,10 @@ cdef class YearBegin(YearOffset):
23612402
>>> ts + pd.offsets.YearBegin()
23622403
Timestamp('2024-01-01 00:00:00')
23632404
2405+
>>> ts = pd.Timestamp(2022, 1, 1)
2406+
>>> ts + pd.offsets.YearBegin(month=2)
2407+
Timestamp('2022-02-01 00:00:00')
2408+
23642409
If you want to get the start of the current year:
23652410
23662411
>>> ts = pd.Timestamp(2023, 1, 1)

0 commit comments

Comments
 (0)