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

Enhance Grain adding Semester #99

Closed
AugustoCL opened this issue Nov 1, 2020 · 9 comments
Closed

Enhance Grain adding Semester #99

AugustoCL opened this issue Nov 1, 2020 · 9 comments

Comments

@AugustoCL
Copy link

Would be a good enhancement add the semester into the grain.

@jbogaardt
Copy link
Collaborator

jbogaardt commented Nov 2, 2020

This functionality is currently not supported in pandas. See pandas-dev/pandas#22362. There is no easy workaround using freq='2Q' due to this bug in pandas: pandas-dev/pandas#15063. Because of these issues, I think this one may take a while to resolve.

Any suggestions on workarounds welcome.

@telferm57
Copy link

I think another use case for this (and possibly more widely needed?) is selecting half year. Many reports require division in to half year (I am working on a few atm) - the functionality could be modelled on quarter , defining the month start for the half year (which would probably coincide with financial year ends, product launches, drug authorizations etc.). As previously noted, we cannot use a frequency of 2Q , because if there happens to be no data in January, but some in Feb it will start the 2 quarter period in February. It seems to be quite a big bit of functionality to be missing given the richness of the time period specification as a whole.

@jbogaardt
Copy link
Collaborator

I believe this is already available in the latest release 0.8.10. Grain = 'OSDS' would be Origin Semester, Development Semester.

@kennethshsu
Copy link
Collaborator

Confirmed that OSDS works.

Does it make more sense to use H instead of S for half year? I think it also makes sense to have the origin text as YYYYH1 and YYYYH2 instead of YYYYQ1 and YYYYQ3 when in OS. Thoughts?

@jbogaardt
Copy link
Collaborator

Maybe support both H and S so as to avoid a deprecation. Both are suboptimal since S is reserved for seconds and H for hours in the datetime module. As labeling goes, your suggestion is a good one.

jbogaardt added a commit that referenced this issue Feb 24, 2022
@telferm57
Copy link

Could use 'h' for half year ? That is not used in strftime or groupby frequencies

@kennethshsu
Copy link
Collaborator

I agree that H more visually pleasing. A new version is coming!

If origin_grain is "S" or "H" (we'll support both), the table will show YYYYH1 YYYYH2, etc.

Sorry I don't have example code here to show, since there's no sample data that is at the monthly or quarterly level origin grain.

@jbogaardt
Copy link
Collaborator

The prism dataset is monthly

@kennethshsu
Copy link
Collaborator

Oh yes! Thanks!

import pandas as pd
import chainladder as cl

prism = cl.load_sample("prism")
prism["Incurred"].sum().grain("OHDM")
prism["Incurred"].sum().grain("OSDM")

These should all work. I also tested some weird mutation and didn't get anything unexpected back.

jbogaardt added a commit that referenced this issue Mar 5, 2022
Fixed origin_as_datetime bug in to_frame() and suppressed warnings #268, Support "H" and "S" for origin_grain, and better formatting per #99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants