8000 BUG-24212 fix when other_index has incompatible dtype by JustinZhengBC · Pull Request #25009 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG-24212 fix when other_index has incompatible dtype #25009

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

Merged
merged 30 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b04cee7
BUG-24212 fix usage of Index.take in pd.merge
JustinZhengBC Jan 11, 2019
a64b8fe
BUG-24212 add comment
JustinZhengBC Jan 11, 2019
022643d
BUG-24212 clarify test
JustinZhengBC Jan 12, 2019
e99dece
BUG-24212 make _create_join_index function
JustinZhengBC Jan 14, 2019
b95e1fe
BUG-24212 add docstring and comments
JustinZhengBC Jan 17, 2019
73be0d0
BUG-24212 fix regression
JustinZhengBC Jan 24, 2019
de3e2c7
BUG-24212 alter old test
JustinZhengBC Jan 24, 2019
1287758
fix typo
JustinZhengBC Jan 24, 2019
bdce7ac
BUG-24212 remove print and move whatsnew note
JustinZhengBC Jan 24, 2019
83ae393
BUG-24212 fix when other_index has incompatible dtype
JustinZhengBC Jan 29, 2019
4cb3ab0
Merge branch 'master' into BUG-24212
JustinZhengBC Jan 29, 2019
66f6fe4
merge issue
JustinZhengBC Jan 29, 2019
cf6fa14
fix whatsnew
JustinZhengBC Jan 29, 2019
0e6de81
BUG-24212 fix test
JustinZhengBC Jan 29, 2019
1da789a
BUG-24212 fix test
JustinZhengBC Jan 29, 2019
a0e5ffc
Merge branch 'BUG-24212' of https://github.com/justinzhengbc/pandas i…
JustinZhengBC Jan 29, 2019
27cdbc8
BUG-24212 simplify take logic
JustinZhengBC Jan 31, 2019
cd326b2
fix import order
JustinZhengBC Jan 31, 2019
2c65ebf
Merge branch 'master' into BUG-24212
JustinZhengBC Mar 26, 2019
d8d3cdf
make logic more generic
JustinZhengBC Mar 26, 2019
f9e7386
make logic more generic
JustinZhengBC Mar 26, 2019
8a36130
Merge branch 'BUG-24212' of https://github.com/justinzhengbc/pandas i…
JustinZhengBC Mar 27, 2019
7da3655
clean up test
JustinZhengBC Mar 29, 2019
17c5497
use compat=False for na_value_for_dtype
JustinZhengBC Mar 29, 2019
720dfbb
Merge branch 'master' into BUG-24212
JustinZhengBC Apr 21, 2019
6772618
clarify whatsnew
JustinZhengBC Apr 22, 2019
dacb4bc
Merge branch 'master' into BUG-24212
JustinZhengBC Apr 22, 2019
cad4398
add PR number to whatsnew
JustinZhengBC Apr 22, 2019
5e2eb0f
Merge branch 'BUG-24212' of https://github.com/justinzhengbc/pandas i…
JustinZhengBC Apr 22, 2019
88cdf8b
Merge branch 'master' into BUG-24212
JustinZhengBC Apr 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BUG-24212 alter old test
  • Loading branch information
JustinZhengBC committed Jan 24, 2019
commit de3e2c71208a6fb52a9315cf4240ed12a67520f0
1 change: 1 addition & 0 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ def _get_join_info(self):

if self.right_index:
if len(self.left) > 0:
print(left_indexer)
join_index = self._create_join_index(self.left.index,
self.right.index,
left_indexer,
Expand Down
26 changes: 3 additions & 23 deletions pandas/tests/reshape/merge/test_merge.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -939,31 +939,11 @@ def test_merge_two_empty_df_no_division_error(self):
with np.errstate(divide='raise'):
merge(a, a, on=('a', 'b'))

@pytest.mark.parametrize('how', ['left', 'outer'])
def test_merge_on_index_with_more_values(self, how):
# GH 24212
# pd.merge gets [-1, -1, 0, 1] as right_indexer, ensure that -1 is
# interpreted as a missing value instead of the last element
df1 = pd.DataFrame([[1, 2], [2, 4], [3, 6], [4, 8]],
columns=['a', 'b'])
df2 = pd.DataFrame([[3, 30], [4, 40]],
columns=['a', 'c'])
df1.set_index('a', drop=False, inplace=True)
df2.set_index('a', inplace=True)
result = pd.merge(df1, df2, left_index=True, right_on='a', how=how)
expected = pd.DataFrame([[1, 2, np.nan],
[2, 4, np.nan],
[3, 6, 30.0],
[4, 8, 40.0]],
columns=['a', 'b', 'c'])
expected.set_index('a', drop=False, inplace=True)
assert_frame_equal(result, expected)

@pytest.mark.parametrize('how', ['right', 'outer'])
def test_merge_on_index_with_more_values(self, how):
# GH 24212
# pd.merge gets [-1, -1, 0, 1] as right_indexer, ensure that -1 is
# interpreted as a missing value instead of the last element
# pd.merge gets [0, 1, 2, -1, -1, -1] as left_indexer, ensure that
# -1 is interpreted as a missing value instead of the last element
df1 = pd.DataFrame({'a': [1, 2, 3], 'key': [0, 2, 2]})
df2 = pd.DataFrame({'b': [1, 2, 3, 4, 5]})
result = df1.merge(df2, left_on='key', right_index=True, how=how)
Expand All @@ -984,7 +964,7 @@ def test_merge_right_index_right(self):
left = pd.DataFrame({'a': [1, 2, 3], 'key': [0, 1, 1]})
right = pd.DataFrame({'b': [1, 2, 3]})

expected = pd.DataFrame({'a': [1, 2, 3, None],
expected = pd.DataFrame({'a': [1, 2, 3, None, None, None],
'key': [0, 1, 1, 2],
'b': [1, 2, 2, 3]},
columns=['a', 'key', 'b'],
Expand Down
0