-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: first("2M") returning incorrect results #38446
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
If we decide to backport, we could cherry pick this one on top of the other Commit. But I am not quite sure either if we should backport. |
we can just revert the original and then merge to master |
Oh right, that would work. Should I open a Revert PR? |
Ok, thx. Will adjust this one after the other is merged |
after the revert is merged, will reopen issue and change milestone. so can update the OP here to close issue again. |
…623_fix � Conflicts: � pandas/core/generic.py � pandas/tests/frame/methods/test_first_and_last.py
Done. This fixes both cases now. |
doc/source/whatsnew/v1.2.0.rst
Outdated
@@ -607,6 +607,7 @@ Datetimelike | |||
- Bug in :meth:`Series.isin` with ``datetime64[ns]`` dtype and :meth:`.DatetimeIndex.isin` failing to consider timezone-aware and timezone-naive datetimes as always different (:issue:`35728`) | |||
- Bug in :meth:`Series.isin` with ``PeriodDtype`` dtype and :meth:`PeriodIndex.isin` failing to consider arguments with different ``PeriodDtype`` as always different (:issue:`37528`) | |||
- Bug in :class:`Period` constructor now correctly handles nanoseconds in the ``value`` argument (:issue:`34621` and :issue:`17053`) | |||
- Bug in :meth:`DataFrame.first` and :meth:`Series.first` returning two months for offset one month when first day is last calendar day (:issue:`29623`) |
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.
so we have three options
- include in 1.2
- change to 1.3
- hold-off merging for a week or so, and then include in 1.2.1
i'm ok with 2 or 3, not so keen on 1.
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.
3. hold-off merging for a week or so
actually, no harm in adding a 1.2.1 whatsnew now.
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.
I am fine with either one of them
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.
ok let's push on 1.3
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.
Done
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.
changes look fine, let' sput on 1.3
doc/source/whatsnew/v1.2.0.rst
Outdated
@@ -607,6 +607,7 @@ Datetimelike | |||
- Bug in :meth:`Series.isin` with ``datetime64[ns]`` dtype and :meth:`.DatetimeIndex.isin` failing to consider timezone-aware and timezone-naive datetimes as always different (:issue:`35728`) | |||
- Bug in :meth:`Series.isin` with ``PeriodDtype`` dtype and :meth:`PeriodIndex.isin` failing to consider arguments with different ``PeriodDtype`` as always different (:issue:`37528`) | |||
- Bug in :class:`Period` constructor now correctly handles nanoseconds in the ``value`` argument (:issue:`34621` and :issue:`17053`) | |||
- Bug in :meth:`DataFrame.first` and :meth:`Series.first` returning two months for offset one month when first day is last calendar day (:issue:`29623`) |
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.
ok let's push on 1.3
pandas/core/generic.py
Outdated
if not isinstance(offset, Tick) and offset.is_on_offset(self.index[0]): | ||
# GH#29623 if first value is end of period, remove offset with n = 1 | ||
# before adding the real offset | ||
end_date = end = self.index[0] - to_offset(offset.name) + offset |
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.
offset.base
instead of to_offset(offset.name)
?
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.
Better:) thx
thanks @phofl |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
This would fix #29623 for offsets with n > 1
cc @simonjayhawkins