-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
BUG: Ignore division by 0 when merging empty dataframes (#17776) #17846
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17846 +/- ##
==========================================
- Coverage 91.25% 91.21% -0.05%
==========================================
Files 163 163
Lines 50038 50040 +2
==========================================
- Hits 45661 45642 -19
- Misses 4377 4398 +21
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17846 +/- ##
==========================================
- Coverage 91.25% 91.21% -0.05%
==========================================
Files 163 163
Lines 50038 50040 +2
==========================================
- Hits 45661 45642 -19
- Misses 4377 4398 +21
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17846 +/- ##
==========================================
- Coverage 91.25% 91.21% -0.05%
==========================================
Files 163 163
Lines 50038 50040 +2
==========================================
- Hits 45661 45642 -19
- Misses 4377 4398 +21
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17846 +/- ##
==========================================
- Coverage 91.35% 91.33% -0.02%
==========================================
Files 163 163
Lines 49801 49802 +1
==========================================
- Hits 45496 45487 -9
- Misses 4305 4315 +10
Continue to review full report at Codecov.
|
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 add the test from the original issue
pandas/core/reshape/merge.py
Outdated
@@ -1514,6 +1514,7 @@ def _sort_labels(uniques, left, right): | |||
|
|||
|
|||
def _get_join_keys(llab, rlab, shape, sort): | |||
np.seterr(divide='ignore') | |||
|
|||
# how many levels can be done without overflow | |||
pred = lambda i: not is_int64_overflow_possible(shape[:i]) |
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.
use the context manager here (and only surround the actual divide statement)
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.
need you to rebase on master
then fix any conflicts
|
ccbf927
to
7aee0b2
Compare
pandas/core/reshape/merge.py
Outdated
lkey += llab[i] * stride | ||
rkey += rlab[i] * stride | ||
np.seterr(divide='warn') |
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.
not necessary
pandas/tests/reshape/test_merge.py
Outdated
@@ -861,6 +861,14 @@ def test_validation(self): | |||
result = merge(left, right, on=['a', 'b'], validate='1:1') | |||
assert_frame_equal(result, expected_multi) | |||
|
|||
def test_merge_two_empty_df_no_division_error(self): | |||
# GH17776, PR #17846 | |||
import warnings |
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.
the test should mimic the one from the issue, except use a context manager (to avoid setting it globally)
pandas/core/reshape/merge.py
Outdated
@@ -1514,6 +1514,7 @@ def _sort_labels(uniques, left, right): | |||
|
|||
|
|||
def _get_join_keys(llab, rlab, shape, sort): | |||
np.seterr(divide='ignore') |
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.
not needed
@jreback, thanks, I've made the changes. How can I address the failed AppVeyor build? This test passed when I ran
|
can you rebase and add a note in 0.21.1 |
thanks @yeemey |
…7776) (pandas-dev#17846) (cherry picked from commit 262e8ff)
git diff upstream/master -u -- "*.py" | flake8 --diff