Skip to content

Commit 7fc6441

Browse files
author
Nico Cernek
committed
rename vars and add comment for clarity
1 parent 3c1a7cb commit 7fc6441

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/core/reshape/merge.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,17 +1319,19 @@ def _get_join_indexers(
13191319
# `count` is the num. of unique keys
13201320
# set(lkey) | set(rkey) == range(count)
13211321

1322+
# flip left and right keys if performing a right merge
1323+
# to preserve right merge row order (GH 27453)
13221324
if how == "right":
1323-
rkey, lkey, count = fkeys(rkey, lkey)
1325+
factorized_rkey, factorized_lkey, count = fkeys(rkey, lkey)
13241326
else:
1325-
lkey, rkey, count = fkeys(lkey, rkey)
1327+
factorized_lkey, factorized_rkey, count = fkeys(lkey, rkey)
13261328
# preserve left frame order if how == 'left' and sort == False
13271329
kwargs = copy.copy(kwargs)
13281330
if how == "left":
13291331
kwargs["sort"] = sort
13301332
join_func = _join_functions[how]
13311333

1332-
return join_func(lkey, rkey, count, **kwargs)
1334+
return join_func(factorized_lkey, factorized_rkey, count, **kwargs)
13331335

13341336

13351337
def _restore_dropped_levels_multijoin(

0 commit comments

Comments
 (0)