Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
Currently, you can generate quarters that fit the 4-4-5 fiscal calendar as is common in the retail world. https://pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.FY5253Quarter.html
How can I generate a datetime index by month (generating a "future" dataframe for forecasting purposes) that matches the input data which is monthly & follows that 4-4-5 calendar?
For example, input data covers these time periods:
['2020-07-05 00:00:00', '2020-08-02 00:00:00', '2020-08-30 00:00:00', '2020-10-04 00:00:00', '2020-11-01 00:00:00', '2020-11-29 00:00:00', '2021-01-03 00:00:00', '2021-01-31 00:00:00', '2021-02-28 00:00:00', '2021-04-04 00:00:00', '2021-05-02 00:00:00', '2021-05-30 00:00:00', '2021-07-04 00:00:00', '2021-08-01 00:00:00', '2021-08-29 00:00:00', '2021-10-03 00:00:00', '2021-10-31 00:00:00', '2021-11-28 00:00:00', '2022-01-02 00:00:00', '2022-01-30 00:00:00', '2022-02-27 00:00:00', '2022-04-03 00:00:00', '2022-05-01 00:00:00', '2022-05-29 00:00:00', '2022-07-03 00:00:00', '2022-07-31 00:00:00', '2022-08-28 00:00:00', '2022-10-02 00:00:00', '2022-10-30 00:00:00', '2022-11-27 00:00:00', '2023-01-01 00:00:00']
I can generate the quarters that match up with this frequency by using the following code:
yoffset = pd.offsets.FY5253Quarter(weekday=6, startingMonth=8, variation="last") yindex = pd.date_range('2020-08-30', periods=12, freq=yoffset) yindex
which in turn generates the correct output:
DatetimeIndex(['2020-08-30', '2020-11-29', '2021-02-28', '2021-05-30', '2021-08-29', '2021-11-28', '2022-02-27', '2022-05-29', '2022-08-28', '2022-11-27', '2023-02-26', '2023-05-28'], dtype='datetime64[ns]', freq='REQ-L-AUG-SUN-1')
How can I resample these quarterly periods to generate an equivalent 4-4-5 monthly frequency that follows the same ruleset?
Feature Description
pd.offsets.FY5253Month(weekday=x, startingMonth=y, variation="z)
Alternative Solutions
Not aware of any and currently stuck
Additional Context
No response