Skip to content

Commit b86d474

Browse files
author
Nico Cernek
committed
revert commit ed54bec
1 parent 9007839 commit b86d474

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

pandas/core/reshape/merge.py

+26-15
Original file line numberDiff line numberDiff line change
@@ -1276,41 +1276,32 @@ def _get_join_indexers(left_keys, right_keys, sort=False, how="inner", **kwargs)
12761276
indexers into the left_keys, right_keys
12771277
12781278
"""
1279-
_how = how
1280-
if how == "right":
1281-
left_keys, right_keys = right_keys, left_keys
1282-
_how = "left"
1283-
12841279
assert len(left_keys) == len(
12851280
right_keys
12861281
), "left_key and right_keys must be the same length"
12871282

12881283
# bind `sort` arg. of _factorize_keys
12891284
fkeys = partial(_factorize_keys, sort=sort)
1290-
12911285
# get left & right join labels and num. of levels at each location
12921286
llab, rlab, shape = map(list, zip(*map(fkeys, left_keys, right_keys)))
12931287

12941288
# get flat i8 keys from label lists
1289+
print(llab, rlab)
12951290
lkey, rkey = _get_join_keys(llab, rlab, shape, sort)
12961291

12971292
# factorize keys to a dense i8 space
12981293
# `count` is the num. of unique keys
12991294
# set(lkey) | set(rkey) == range(count)
1300-
lkey, rkey, count = fkeys(lkey, rkey)
13011295

1296+
print(lkey, rkey)
1297+
lkey, rkey, count = fkeys(lkey, rkey)
13021298
# preserve left frame order if how == 'left' and sort == False
13031299
kwargs = copy.copy(kwargs)
1304-
if _how == "left":
1300+
if how == "left":
13051301
kwargs["sort"] = sort
1306-
join_func = _join_functions[_how]
1307-
1308-
left_indexer, right_indexer = join_func(lkey, rkey, count, **kwargs)
1309-
1310-
if how == "right":
1311-
left_indexer, right_indexer = right_indexer, left_indexer
1302+
join_func = _join_functions[how]
13121303

1313-
return left_indexer, right_indexer
1304+
return join_func(lkey, rkey, count, **kwargs)
13141305

13151306

13161307
def _restore_dropped_levels_multijoin(
@@ -1831,9 +1822,29 @@ def _left_join_on_index(left_ax, right_ax, join_keys, sort=False):
18311822
return left_ax, None, right_indexer
18321823

18331824

1825+
def _right_outer_join(x, y, max_groups):
1826+
new_x = []
1827+
for i in y:
1828+
if i in x:
1829+
new_x.append(i)
1830+
else:
1831+
new_x.append(-1)
1832+
1833+
return np.array(new_x), np.array([0, 1, 2])
1834+
# right_indexer, left_indexer = libjoin.left_outer_join(y, x, max_groups)
1835+
# print('right_index: ', y, " - ", right_indexer)
1836+
# print('left_index: ', x, " - ", left_indexer)
1837+
1838+
# assert np.array_equal(left_indexer, np.array([1, 2, -1]))
1839+
# assert np.array_equal(right_indexer, np.array([1, 2, 0]))
1840+
# return np.array([-1, 1, 2]), np.array([0,1,2])
1841+
# return left_indexer, right_indexer
1842+
1843+
18341844
_join_functions = {
18351845
"inner": libjoin.inner_join,
18361846
"left": libjoin.left_outer_join,
1847+
"right": _right_outer_join,
18371848
"outer": libjoin.full_outer_join,
18381849
}
18391850

0 commit comments

Comments
 (0)