Skip to content

Commit d328470

Browse files
author
Nico Cernek
committed
change logic to swap left and right if how==right
1 parent a8954fe commit d328470

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

pandas/core/reshape/merge.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,15 +1312,16 @@ def _get_join_indexers(
13121312
llab, rlab, shape = [list(x) for x in zipped]
13131313

13141314
# get flat i8 keys from label lists
1315-
print(llab, rlab)
13161315
lkey, rkey = _get_join_keys(llab, rlab, shape, sort)
13171316

13181317
# factorize keys to a dense i8 space
13191318
# `count` is the num. of unique keys
13201319
# set(lkey) | set(rkey) == range(count)
13211320

1322-
print(lkey, rkey)
1323-
lkey, rkey, count = fkeys(lkey, rkey)
1321+
if how == "right":
1322+
rkey, lkey, count = fkeys(rkey, lkey)
1323+
else:
1324+
lkey, rkey, count = fkeys(lkey, rkey)
13241325
# preserve left frame order if how == 'left' and sort == False
13251326
kwargs = copy.copy(kwargs)
13261327
if how == "left":
@@ -1857,22 +1858,8 @@ def _left_join_on_index(left_ax: Index, right_ax: Index, join_keys, sort: bool =
18571858

18581859

18591860
def _right_outer_join(x, y, max_groups):
1860-
new_x = []
1861-
for i in y:
1862-
if i in x:
1863-
new_x.append(i)
1864-
else:
1865-
new_x.append(-1)
1866-
1867-
return np.array(new_x), np.array([0, 1, 2])
1868-
# right_indexer, left_indexer = libjoin.left_outer_join(y, x, max_groups)
1869-
# print('right_index: ', y, " - ", right_indexer)
1870-
# print('left_index: ', x, " - ", left_indexer)
1871-
1872-
# assert np.array_equal(left_indexer, np.array([1, 2, -1]))
1873-
# assert np.array_equal(right_indexer, np.array([1, 2, 0]))
1874-
# return np.array([-1, 1, 2]), np.array([0,1,2])
1875-
# return left_indexer, right_indexer
1861+
right_indexer, left_indexer = libjoin.left_outer_join(y, x, max_groups)
1862+
return left_indexer, right_indexer
18761863

18771864

18781865
_join_functions = {

0 commit comments

Comments
 (0)