-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Breaking change to offsets.pyx - quarter offset classes #39890
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
Conversation
pls just one PR - just push to the same one if changing |
ok that's fine you always need a test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you would need to change / add tests to show what is changing. and have the tests pass
does this handle #5307? |
Not at present. I'd like to cover it as well - please let me know if that's OK. |
It does now. |
Update test_startingMonth_deprecation
Add quarter-based offsets' changes to the API breaking changes (Notable bug fixes) section
Description drafted and added. |
BTW, maybe |
doc/source/whatsnew/v1.3.0.rst
Outdated
Quarter-based time offset classes :class:`~pandas.tseries.offsets.QuarterEnd`, | ||
:class:`~pandas.tseries.offsets.QuarterBegin`, :class:`~pandas.tseries.offsets.BQuarterEnd`, | ||
:class:`~pandas.tseries.offsets.BQuarterBegin` now use ``month`` instead of ``startingMonth`` | ||
as a time anchor parameter (:issue:`5307`). Its default value for :class:`~pandas.tseries.offsets.QuarterBegin` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Its" -> "The"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed.
pandas/_libs/tslibs/offsets.pyx
Outdated
|
||
def __init__(self, n=1, normalize=False, startingMonth=None): | ||
def __init__(self, n: int=1, normalize: bool=False, month: int=None, | ||
*, startingMonth: int=None): # GH#5307 backwards compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment on new line # GH#5307 startingMonth retained for backwards compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added.
|
||
def __init__(self, n=1, normalize=False, startingMonth=None): | ||
def __init__(self, n: int=1, normalize: bool=False, month: int=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we try to detect if month is passed as a non-keyword, in which case the behavior may be silently changing?
(if backward compat werent an issue, I'd be OK with making everything other than n
and normalize
keyword-only in all these classes)
raise TypeError("Offset received both month and startingMonth") | ||
elif month is None and startingMonth is not None: | ||
warnings.warn( | ||
"startingMonth is deprecated, use month instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this explain that the meaning has changed? or point to a link?
pandas/_libs/tslibs/offsets.pyx
Outdated
warnings.warn( | ||
"startingMonth is deprecated, use month instead.", | ||
FutureWarning, | ||
stacklevel=2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing comma, pretend we could run black
on this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, hopefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pawel-Kranzberg can you split this change up. There is just too much going on here.
- doc-strings
- deprecation
- breaking change
I would really like to do the deprecation first and separate
@@ -458,6 +458,36 @@ with a :class:`MultiIndex` in the result. This can lead to a perceived duplicati | |||
df.groupby('label1').rolling(1).sum() | |||
|
|||
|
|||
.. _whatsnew_130.notable_bug_fixes.quarterbegin_default_anchor: | |||
|
|||
Changed default periods in :class:`~pandas.tseries.offsets.QuarterBegin` and :class:`~pandas.tseries.offsets.BQuarterBegin` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be the same length as the title, it should error if not
|
||
*pandas 1.3.0* | ||
|
||
.. code-block:: ipython |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use a code-block, rather an ipython block for the new behavior
@@ -458,6 +458,36 @@ with a :class:`MultiIndex` in the result. This can lead to a perceived duplicati | |||
df.groupby('label1').rolling(1).sum() | |||
|
|||
|
|||
.. _whatsnew_130.notable_bug_fixes.quarterbegin_default_anchor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to say deprecation about the startingMonth
as its mentioned below as well. I would prefer making these 2 distinct and unrelated changes (which they are). so don't mention deprecation at all here.
@@ -625,6 +656,7 @@ Datetimelike | |||
- Bug in :meth:`Timedelta.round`, :meth:`Timedelta.floor`, :meth:`Timedelta.ceil` for values near the implementation bounds of :class:`Timedelta` (:issue:`38964`) | |||
- Bug in :func:`date_range` incorrectly creating :class:`DatetimeIndex` containing ``NaT`` instead of raising ``OutOfBoundsDatetime`` in corner cases (:issue:`24124`) | |||
- Bug in :func:`infer_freq` incorrectly fails to infer 'H' frequency of :class:`DatetimeIndex` if the latter has a timezone and crosses DST boundaries (:issue:`39556`) | |||
- Bug in offsets :class:`QuarterBegin` and :class:`BQuarterBegin` returning days that are not conventional quarter beginnings (:issue:`8435`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this a duplicate of the above section?
startingMonth = self._default_starting_month | ||
self.startingMonth = startingMonth | ||
# GH#5307 startingMonth retained for backwards compatibility | ||
if month and startingMonth and month != startingMonth: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you need to check not-none? e.g. 0 is value that would hit this too (which would fail but is misleading no?)
self.startingMonth = state.pop("startingMonth") | ||
try: | ||
self.month = state.pop("month") | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this is non-obvious on the exception.
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
@Pawel-Kranzberg what's the status. close this and open separate PRs? |
Yes, I plan to do so next week. |
Thanks for the PR, but it has appeared to have gone stale. Closing due to inactivity, but we would be happy to take a new PR working on the deprecation first. |
Set default months for
BQuarterEnd
,BQuarterBegin
,QuarterEnd
,QuarterBegin
classes in order; renamestartingMonth
parameter tomonth
for those classes.Addresses #8435 and #5307