Feature Type
-
[X] Adding new functionality to pandas
-
[ ] Changing existing functionality in pandas
-
[ ] Removing existing functionality in pandas
Problem Description
The current implementation of FY5253Quarter assumes that quarters have an even distribution of weeks, for a total of 13 weeks per quarter except in the event of a 53 week year, in which case a designated quarter will consist of a total of 14 weeks.
It is sometimes the case the companies elect to use quarters with an alternative allocation of weeks, the alternative often being 16-12-12-12.
I propose the addition of an optional argument called quarter_lengths
that accepts an input of Tuple[int, int, int, int]
where sum(quarter_lengths) == 52
.
Feature Description
In addition to modifying the interface to include the extra parameter, I think this can be accomplished with a very simple change to the existing get_weeks
function:
https://github.com/pandas-dev/pandas/blob/main/pandas/_libs/tslibs/offsets.pyx#L4052C1-L4060C19
def get_weeks(self, dt: datetime):
ret = self.quarter_lengths or [13] * 4
year_has_extra_week = self.year_has_extra_week(dt)
if year_has_extra_week:
ret[self.qtr_with_extra_week - 1] += 1
return ret
Alternative Solutions
n/a
Additional Context
Example 10-k describing this pattern
Comment From: GTLangseth
I'm also happy to submit a PR if it feels like this is worth adding!