@@ -140,7 +140,7 @@ def test_left_join_index_preserve_order(self):
140
140
141
141
tm .assert_frame_equal (result , expected )
142
142
143
- def test_left_join_index_multi_match_multiindex (self ):
143
+ def test_join_nonunique_multi_rindex (self ):
144
144
left = DataFrame ([
145
145
['X' , 'Y' , 'C' , 'a' ],
146
146
['W' , 'Y' , 'C' , 'e' ],
@@ -155,7 +155,7 @@ def test_left_join_index_multi_match_multiindex(self):
155
155
columns = ['cola' , 'colb' , 'colc' , 'tag' ],
156
156
index = [3 , 2 , 0 , 1 , 7 , 6 , 4 , 5 , 9 , 8 ])
157
157
158
- right = DataFrame ([
158
+ right = ( DataFrame ([
159
159
['W' , 'R' , 'C' , 0 ],
160
160
['W' , 'Q' , 'B' , 3 ],
161
161
['W' , 'Q' , 'B' , 8 ],
@@ -171,7 +171,7 @@ def test_left_join_index_multi_match_multiindex(self):
171
171
['V' , 'R' , 'D' , - 1 ],
172
172
['V' , 'Q' , 'A' , - 3 ]],
173
173
columns = ['col1' , 'col2' , 'col3' , 'val' ])
174
- right .set_index (['col1' , 'col2' , 'col3' ], inplace = True )
174
+ .set_index (['col1' , 'col2' , 'col3' ]) )
175
175
176
176
result = left .join (right , on = ['cola' , 'colb' , 'colc' ], how = 'left' )
177
177
@@ -203,7 +203,7 @@ def test_left_join_index_multi_match_multiindex(self):
203
203
204
204
tm .assert_frame_equal (result , expected )
205
205
206
- def test_left_join_index_multi_match (self ):
206
+ def test_join_nonunique_rindex (self ):
207
207
left = DataFrame ([
208
208
['c' , 0 ],
209
209
['b' , 1 ],
@@ -212,7 +212,7 @@ def test_left_join_index_multi_match(self):
212
212
columns = ['tag' , 'val' ],
213
213
index = [2 , 0 , 1 , 3 ])
214
214
215
- right = DataFrame ([
215
+ right = ( DataFrame ([
216
216
['a' , 'v' ],
217
217
['c' , 'w' ],
218
218
['c' , 'x' ],
@@ -222,8 +222,8 @@ def test_left_join_index_multi_match(self):
222
222
['e' , 'q' ],
223
223
['c' , 's' ]],
224
224
columns = ['tag' , 'char' ])
225
+ .set_index ('tag' ))
225
226
226
- right .set_index ('tag' , inplace = True )
227
227
result = left .join (right , on = 'tag' , how = 'left' )
228
228
229
229
expected = DataFrame ([
@@ -241,8 +241,9 @@ def test_left_join_index_multi_match(self):
241
241
tm .assert_frame_equal (result , expected )
242
242
243
243
result = left .join (right , on = 'tag' , how = 'left' , sort = True )
244
- tm .assert_frame_equal (
245
- result , expected .sort_values ('tag' , kind = 'mergesort' ))
244
+ expected = expected .sort_values ('tag' , kind = 'mergesort' )
245
+
246
+ tm .assert_frame_equal (result , expected )
246
247
247
248
# GH7331 - maintain left frame order in left merge
248
249
result = merge (left , right .reset_index (), how = 'left' , on = 'tag' )
0 commit comments