-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: error calculating BusinessHourMixin.apply for long business hour per day #26381
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
Codecov Report
@@ Coverage Diff @@
## master #26381 +/- ##
==========================================
- Coverage 91.68% 91.67% -0.01%
==========================================
Files 174 174
Lines 50704 50704
==========================================
- Hits 46488 46485 -3
- Misses 4216 4219 +3
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #26381 +/- ##
==========================================
- Coverage 91.68% 91.68% -0.01%
==========================================
Files 174 174
Lines 50704 50738 +34
==========================================
+ Hits 46488 46518 +30
- Misses 4216 4220 +4
Continue to review full report at Codecov.
|
@jiangyue12392 : Thanks for submitting this! For those tests cases that you've added, what happens currently without your fixes? |
@gfyoung The current code without fixes would return a wrong value if the adding of business hour to the timestamp results in an ending time landing in the next business time period. For example, if the working hour is 00:00 to 23:00 and 4 business hours are added at 22:00, the current code would return 02:00 in the next day instead of 03:00 the next business day. |
@jiangyue12392 : I see. For clarify, could you show the output of those examples, using a format like this (we use this format for our issue tracker): Exampleprint("Hello World") This outputs:
|
@gfyoung Example inputs and outputs: bh = BusinessHour(n=4, start='00:00', end='23:00')
dt = datetime(2014, 7, 3, 22)
dt + bh Expected: datetime(2014, 7, 4, 3) Current Output: datetime(2014, 7, 4, 2) |
Got it. Can you add a |
@gfyoung |
@jiangyue12392 : A https://github.com/pandas-dev/pandas/blob/master/doc/source/whatsnew/v0.25.0.rst I recommend adding it under the |
@gfyoung new entry added |
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.
doc/source/whatsnew/v0.25.0.rst
Outdated
@@ -285,7 +285,7 @@ Timedelta | |||
|
|||
- Bug in :func:`TimedeltaIndex.intersection` where for non-monotonic indices in some cases an empty ``Index`` was returned when in fact an intersection existed (:issue:`25913`) | |||
- Bug with comparisons between :class:`Timedelta` and ``NaT`` raising ``TypeError`` (:issue:`26039`) | |||
- | |||
- Bug in adding of business hour to the timestamp with an ending time landing in the next business time period (:pull:`26381`) |
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.
Bug when adding or subtracting a :class:`BusinessHour` to a :class:`Timestamp` with the resulting time landing in a following or prior day respectively (:issue:`26381`)
looks fine, ex- @mroeschke comment on the whatsnew. |
@@ -1287,6 +1287,23 @@ def test_opening_time(self, case): | |||
datetime(2014, 7, 7, 19, 30): datetime(2014, 7, 5, 4, 30), | |||
datetime(2014, 7, 7, 19, 30, 30): datetime(2014, 7, 5, 4, 30, 30)})) | |||
|
|||
# long business hours (see gh-26381) | |||
apply_cases.append((BusinessHour(n=4, start='00:00', end='23:00'), { |
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.
would love a separate PR to split up test_offsets.py a bit :->
lgtm. ping on green. |
Thanks @jiangyue12392, nice work! |
git diff upstream/master -u -- "*.py" | flake8 --diff
Input:
Expected: