-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REGR: allow merging on object boolean columns #21310
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
Changes from all commits
0dfd01e
1630072
fe45b89
1bd8661
58b72c5
ad845d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1526,6 +1526,27 @@ def test_merge_on_ints_floats_warning(self): | |
result = B.merge(A, left_on='Y', right_on='X') | ||
assert_frame_equal(result, expected[['Y', 'X']]) | ||
|
||
def test_merge_incompat_infer_boolean_object(self): | ||
# GH21119: bool + object bool merge OK | ||
df1 = DataFrame({'key': Series([True, False], dtype=object)}) | ||
df2 = DataFrame({'key': [True, False]}) | ||
|
||
expected = DataFrame({'key': [True, False]}, dtype=object) | ||
result = pd.merge(df1, df2, on='key') | ||
assert_frame_equal(result, expected) | ||
result = pd.merge(df2, df1, on='key') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blank lines between cases |
||
assert_frame_equal(result, expected) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ideally use the how fixture There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also not used for the other tests on this, so leaving this for now |
||
|
||
# with missing value | ||
df1 = DataFrame({'key': Series([True, False, np.nan], dtype=object)}) | ||
df2 = DataFrame({'key': [True, False]}) | ||
|
||
expected = DataFrame({'key': [True, False]}, dtype=object) | ||
result = pd.merge(df1, df2, on='key') | ||
assert_frame_equal(result, expected) | ||
result = pd.merge(df2, df1, on='key') | ||
assert_frame_equal(result, expected) | ||
|
||
@pytest.mark.parametrize('df1_vals, df2_vals', [ | ||
([0, 1, 2], ["0", "1", "2"]), | ||
([0.0, 1.0, 2.0], ["0", "1", "2"]), | ||
|
@@ -1538,6 +1559,8 @@ def test_merge_on_ints_floats_warning(self): | |
pd.date_range('20130101', periods=3, tz='US/Eastern')), | ||
([0, 1, 2], Series(['a', 'b', 'a']).astype('category')), | ||
([0.0, 1.0, 2.0], Series(['a', 'b', 'a']).astype('category')), | ||
# TODO ([0, 1], pd.Series([False, True], dtype=bool)), | ||
([0, 1], pd.Series([False, True], dtype=object)) | ||
]) | ||
def test_merge_incompat_dtypes(self, df1_vals, df2_vals): | ||
# GH 9780, GH 15800 | ||
|
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 to test the error case (e.g. bool / inferred bool) on 1 side and numeric on the other (I think this will raise), prob have an existing test, just need to add to it