-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: QuarterBegin and BQuarterBegin return days that are not quarter beginnings #8435
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
Comments
The default startingMonth is 3 (which may be wrong, their is a comment in the code to that effect). You can get what you expect by using a
If you'd like to investigate to see why this is would be appreciated. I don't know when/how this was done this way. |
If any of you have a comment about this: cc @bjonen |
I think I would prefer default QuarterBegin to be 1 |
agreed - seeing if anyone know why it is not 1 (and why 3) |
Just guessing, but there are a few countries whose fiscal years begin in March (month 3): http://en.wikipedia.org/wiki/Fiscal_year, but even then, the QuarterEnd and BQuarterEnd objects don't default to 3 to match. |
I'm inclined to change this default to the standard quarter definition (month begins on 1, 4, 7, 10 and month ends on 3, 6, 9, 12). Any objections? It is wrong and inconsistent now:
|
Related to #5307 probably. |
@jreback, I'm running into this issue fixing #11370 - I agree with the comments above that the current definition is inconsistent. But I suppose it would need to go through a deprecation cycle where it's breaking? cc @sinhrks edit: on second thought I guess # start / end definition for period is symmetrical
In [43]: pd.period_range('2014-1-1', periods=5, freq='Q-DEC').to_timestamp(how='e')
Out[43]:
DatetimeIndex(['2014-03-31', '2014-06-30', '2014-09-30', '2014-12-31',
'2015-03-31'],
dtype='datetime64[ns]', freq='Q-DEC')
In [44]: pd.period_range('2014-1-1', periods=5, freq='Q-DEC').to_timestamp(how='s')
Out[44]:
DatetimeIndex(['2014-01-01', '2014-04-01', '2014-07-01', '2014-10-01',
'2015-01-01'],
dtype='datetime64[ns]', freq='QS-OCT')
# not so for QuarterBegin / QuarterEnd
In [46]: pd.date_range('2014-1-1', periods=5, freq='Q-DEC')
Out[46]:
DatetimeIndex(['2014-03-31', '2014-06-30', '2014-09-30', '2014-12-31',
'2015-03-31'],
dtype='datetime64[ns]', freq='Q-DEC')
In [47]: pd.date_range('2014-1-1', periods=5, freq='QS-DEC')
Out[47]:
DatetimeIndex(['2014-03-01', '2014-06-01', '2014-09-01', '2014-12-01',
'2015-03-01'],
dtype='datetime64[ns]', freq='QS-DEC') |
Those are months of IMM dates. |
as discussed in #14254 this should be changed in 0.20. In order to make this back-compat, I will propose that we show a warning if
|
+1 |
any appetite for this one? |
Also, these offsets seem to be poorly documented. I had no idea there was an option for |
Pushing as not a blocker for 1.0 |
Hi, what is the status of this issue? It really produces highly unexpected behavior, especially in context of documentation and function QuarterEnd - the fact that for Quarter end to have startingMonth = 3 and quarter ending on 31st of March, while Quarter begin gives 1st of March makes no sense together. I believe they should have defualt starting month equal to 1 (as the financial example is surely a minority case), and while quarterEnd by default should return the same value, quarter begin should return 1st of January... |
@Darrrian happy to take a patch which deprecates - if u read the issue and the related ones there is no objection to the change |
This is not even self-consistent without startingMonth=1:
|
I am amazed to see that this discussion has been going on for almost 10 years and there still does not seem to be any conclusion to it.
But then I expect
Instead, I have to set
|
Agree, this is really odd:
I'd also like to change The way forwards may be:
Though aside from the default, I'll bring this up in the next call |
Okay, whoever and for whatever reasons decided that 3 would be the best default for startingMonth, I honestly do not care, but this has not been fixed for an entire DECADE. Come on... |
@rt87 :
People on every historic issue: "this hasn't been fixed in a decade, just change it already!" People if/when it gets changed: "this broke my code, stop changing things!" This could be changed as a breaking change in 3.0, but I'm not sure I have the energy to deal with potential backlash |
@rt87 So maybe fix it instead of being rude... Problem is that startingMonth = 3 is not the problem, the problem is that the 2 functions are incosistent together... |
OF COURSE it may break something. Since when is this a reason not to fix things? Such thoughts always remind me of https://xkcd.com/1172/. By that logic, the XKCD heat problem will remain till the end of time... XD. Also, did you stop to think about all apps that may be working incorrectly beause of this? Past, present and future? Yes, the responsible DEVs should have tested their code, but nonetheless.... So, call me rude all you want, I am sticking with "needs to be fixed!". Not that anyone seems interested in my opinion, but I strongly feel that procrastinating is not the way to go here. And btw I never said "just screw everyone and flip the switch tomorrow". After all, there are means to handle breaking changes. Introduce deprecations etc..., if that would have been implemented said decade ago, this issue would now be solved. And following that train of thought: Even if I do not really like it, libs DO introduce breaking changes in minor versions. Yes, they shouldn't, but sometimes it is warranted, e.g. for fixing bugs... I'm obviously not in charge of this, so fix it in v2.x, fix it in v3, or just never fix it at all. Decide as you see fit! This is just my two cents regarding bugs, and I will continue to think (and speak) "Come on..." when known bugs have not been addressed for such a long time. |
In[43]: datetime(2014,10,10) + BQuarterBegin()
Out[43]: Timestamp('2014-12-01 00:00:00')
In[45]: datetime(2014,10,10) + QuarterBegin()
Out[45]: Timestamp('2014-12-01 00:00:00')
Expected output is 2015-01-01.
(Note QuarterEnd and BQuarterEnd do produce the expected output of 2014-12-31)
The text was updated successfully, but these errors were encountered: