Skip to content
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

ENH: FY5253Quarter to support alternative week allocations #58272

Open
1 of 3 tasks
GTLangseth opened this issue Apr 16, 2024 · 1 comment
Open
1 of 3 tasks

ENH: FY5253Quarter to support alternative week allocations #58272

GTLangseth opened this issue Apr 16, 2024 · 1 comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@GTLangseth
Copy link

Feature Type

  • 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

@GTLangseth GTLangseth added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 16, 2024
@GTLangseth
Copy link
Author

I'm also happy to submit a PR if it feels like this is worth adding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant