Skip to content

Commit

Permalink
refactor: replace custom _merge using pd.merge
Browse files Browse the repository at this point in the history
  • Loading branch information
deepyaman authored and cpcloud committed Jun 23, 2023
1 parent 51b5ef8 commit fe74f76
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions ibis/backends/tests/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,14 @@ def _pandas_anti_join(left, right, on, **_):
return inner[inner["_merge"] == "left_only"]


def _merge(
left,
right,
on,
*,
how,
suffixes=("", "_y"),
):
joined = pd.merge(
left,
right,
on=on,
how=how,
suffixes=suffixes,
indicator=True,
)
if how == "right":
filt_key = {"left_only"}
elif how == "left":
filt_key = {"right_only"}
else:
filt_key = set()

joined.loc[joined["_merge"].isin(filt_key), on] = np.nan
return joined.drop(["_merge"], axis=1)


IMPLS = {
"semi": _pandas_semi_join,
"anti": _pandas_anti_join,
}


def check_eq(left, right, how, **kwargs):
impl = IMPLS.get(how, _merge)
impl = IMPLS.get(how, pd.merge)
return impl(left, right, how=how, **kwargs)


Expand Down

0 comments on commit fe74f76

Please sign in to comment.