From c53484894ff631e5929b065498c84222b785db4d Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 1 Aug 2022 17:12:46 -0400 Subject: [PATCH] feat(pandas): implement Contains with a group by --- ibis/backends/pandas/execution/generic.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ibis/backends/pandas/execution/generic.py b/ibis/backends/pandas/execution/generic.py index 54ee67ca2f06..0be98398e62b 100644 --- a/ibis/backends/pandas/execution/generic.py +++ b/ibis/backends/pandas/execution/generic.py @@ -982,6 +982,17 @@ def execute_node_contains_series_sequence(op, data, elements, **kwargs): return data.isin(elements) +@execute_node.register( + ops.Contains, + SeriesGroupBy, + (collections.abc.Sequence, collections.abc.Set, pd.Series), +) +def execute_node_contains_series_group_by_sequence( + op, data, elements, **kwargs +): + return data.obj.isin(elements).groupby(data.grouper.groupings) + + @execute_node.register( ops.NotContains, pd.Series,