Skip to content

DOC: add examples to offsets classes: FY5253, FY5253Quarter #54608

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 3 commits into from
Aug 21, 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
47 changes: 47 additions & 0 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3540,6 +3540,9 @@ cdef class FY5253(FY5253Mixin):
Parameters
----------
n : int
The number of fiscal years represented.
normalize : bool, default False
Normalize start/end dates to midnight before generating date range.
weekday : int {0, 1, ..., 6}, default 0
A specific integer for the day of the week.

Expand All @@ -3562,11 +3565,31 @@ cdef class FY5253(FY5253Mixin):
- "nearest" means year end is **weekday** closest to last day of month in year.
- "last" means year end is final **weekday** of the final month in fiscal year.

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

Examples
--------
In the example below the default parameters give the next 52-53 week fiscal year.

>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.FY5253()
Timestamp('2022-01-31 00:00:00')

By the parameter ``startingMonth`` we can specify
the month in which fiscal years end.

>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.FY5253(startingMonth=3)
Timestamp('2022-03-28 00:00:00')

52-53 week fiscal year can be specified by
``weekday`` and ``variation`` parameters.

>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.FY5253(weekday=5, startingMonth=12, variation="last")
Timestamp('2022-12-31 00:00:00')
"""

_prefix = "RE"
Expand Down Expand Up @@ -3720,6 +3743,9 @@ cdef class FY5253Quarter(FY5253Mixin):
Parameters
----------
n : int
The number of business quarters represented.
normalize : bool, default False
Normalize start/end dates to midnight before generating date range.
weekday : int {0, 1, ..., 6}, default 0
A specific integer for the day of the week.

Expand All @@ -3745,11 +3771,32 @@ cdef class FY5253Quarter(FY5253Mixin):
- "nearest" means year end is **weekday** closest to last day of month in year.
- "last" means year end is final **weekday** of the final month in fiscal year.

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

Examples
--------
In the example below the default parameters give
the next business quarter for 52-53 week fiscal year.

>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.FY5253Quarter()
Timestamp('2022-01-31 00:00:00')

By the parameter ``startingMonth`` we can specify
the month in which fiscal years end.

>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.FY5253Quarter(startingMonth=3)
Timestamp('2022-03-28 00:00:00')

Business quarters for 52-53 week fiscal year can be specified by
``weekday`` and ``variation`` parameters.

>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.FY5253Quarter(weekday=5, startingMonth=12, variation="last")
Timestamp('2022-04-02 00:00:00')
"""

_prefix = "REQ"
Expand Down