From c4276574ef9704c39a9ffedf5d6ccfd5ef7cf26b Mon Sep 17 00:00:00 2001 From: tp Date: Fri, 20 Dec 2019 22:03:18 +0000 Subject: [PATCH] CLN: move code out of try clause in merge.py --- pandas/core/reshape/merge.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index 0fb029c8429a6..3dfd5fed34741 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -116,20 +116,20 @@ def _groupby_and_merge( # if we can groupby the rhs # then we can get vastly better perf - try: - # we will check & remove duplicates if indicated - if check_duplicates: - if on is None: - on = [] - elif not isinstance(on, (list, tuple)): - on = [on] - - if right.duplicated(by + on).any(): - _right = right.drop_duplicates(by + on, keep="last") - # TODO: use overload to refine return type of drop_duplicates - assert _right is not None # needed for mypy - right = _right + # we will check & remove duplicates if indicated + if check_duplicates: + if on is None: + on = [] + elif not isinstance(on, (list, tuple)): + on = [on] + + if right.duplicated(by + on).any(): + _right = right.drop_duplicates(by + on, keep="last") + # TODO: use overload to refine return type of drop_duplicates + assert _right is not None # needed for mypy + right = _right + try: rby = right.groupby(by, sort=False) except KeyError: rby = None