-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix bugs in WeekOfMonth.apply, Week.onOffset #18875
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
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.
comments. looks good after changes. ping on green.
doc/source/whatsnew/v0.23.0
Outdated
@@ -362,3 +362,4 @@ Other | |||
|
|||
- Improved error message when attempting to use a Python keyword as an identifier in a ``numexpr`` backed query (:issue:`18221`) | |||
- Bug in :class:`Timestamp` where comparison with an array of ``Timestamp`` objects would result in a ``RecursionError`` (:issue:`15183`) |
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.
pls move both this and the one higher to conversion. pls dont' put things in Other that fit elsewhere.
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. Out of curiosity, what is the heuristic that gets this lumped into "conversion"?
tz = other.tzinfo | ||
naive = other.replace(tzinfo=None) | ||
shifted = naive + timedelta(days=days) | ||
return tslib._localize_pydatetime(shifted, tz) |
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.
side issue. _localize_pydatetime
is in the wrong place (its in tslib) should be in conversion.pyx. And It shouldn't just return on None
as well, and needs a better doc-string. can you add to list.
pandas/tseries/offsets.py
Outdated
d = datetime(dt.year, dt.month, dt.day, tzinfo=dt.tzinfo) | ||
return d == self.getOffsetOfMonth(dt) | ||
def _get_offset_day(self, other): | ||
mstart = datetime(other.year, other.month, 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.
can you document
pandas/tseries/offsets.py
Outdated
return False | ||
return dt == self.getOffsetOfMonth(dt) | ||
def _get_offset_day(self, other): | ||
dim = ccalendar.get_days_in_month(other.year, other.month) |
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.
same
doc/source/whatsnew/v0.23.0
Outdated
@@ -362,3 +362,4 @@ Other | |||
|
|||
- Improved error message when attempting to use a Python keyword as an identifier in a ``numexpr`` backed query (:issue:`18221`) | |||
- Bug in :class:`Timestamp` where comparison with an array of ``Timestamp`` objects would result in a ``RecursionError`` (:issue:`15183`) | |||
- Bug in :class:`WeekOfMonth` and class:`Week` where addition and subtraction did not roll correctly (:issue:`18672`,:issue:`18510`) |
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.
there is a 3rd issue no?
Codecov Report
@@ Coverage Diff @@
## master #18875 +/- ##
==========================================
- Coverage 91.65% 91.64% -0.01%
==========================================
Files 154 154
Lines 51368 51364 -4
==========================================
- Hits 47080 47074 -6
- Misses 4288 4290 +2
Continue to review full report at Codecov.
|
Ping |
thanks! |
In the process we get rid of
WeekOfMonth.getOffsetOfMonth
andLastWeekOfMonth.getOffsetOfMonth
, which were idiosyncratic what arguments they passed todatetime
.The issues this addresses are orthogonal to #18762, but the code affected does overlap. In particular, after this,
roll_monthday
will not be needed in 18762.closes #18864
closes #18672
closes #18510
git diff upstream/master -u -- "*.py" | flake8 --diff