Skip to content

Commit

Permalink
Revert "feat(python): Expose 'strict' argument to 'is_in'" (pola-rs#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jul 23, 2024
1 parent 6f8b478 commit 0e775bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
13 changes: 3 additions & 10 deletions py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5724,21 +5724,14 @@ def xor(self, other: Any) -> Expr:
"""
return self.__xor__(other)

def is_in(
self, other: Expr | Collection[Any] | Series, *, strict: bool = True
) -> Expr:
def is_in(self, other: Expr | Collection[Any] | Series) -> Expr:
"""
Check if elements of this expression are present in the other Series.
Parameters
----------
other
Series or sequence to test membership of.
strict
If a python collection is given, `strict`
will be passed to the `Series` constructor
and indicates how different types should be
handled.
Series or sequence of primitive type.
Returns
-------
Expand All @@ -5765,7 +5758,7 @@ def is_in(
if isinstance(other, Collection) and not isinstance(other, str):
if isinstance(other, (Set, FrozenSet)):
other = list(other)
other = F.lit(pl.Series(other, strict=strict))._pyexpr
other = F.lit(pl.Series(other))._pyexpr
else:
other = parse_into_expression(other)
return self._from_pyexpr(self._pyexpr.is_in(other))
Expand Down
12 changes: 1 addition & 11 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3703,20 +3703,10 @@ def is_not_nan(self) -> Series:
]
"""

def is_in(self, other: Series | Collection[Any], *, strict: bool = True) -> Series:
def is_in(self, other: Series | Collection[Any]) -> Series:
"""
Check if elements of this Series are in the other Series.
Parameters
----------
other
Series or sequence to test membership of.
strict
If a python collection is given, `strict`
will be passed to the `Series` constructor
and indicates how different types should be
handled.
Returns
-------
Series
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,3 @@ def test_is_first_last_distinct_all_null(dtypes: PolarsDataType) -> None:
s = pl.Series([None, None, None], dtype=dtypes)
assert s.is_first_distinct().to_list() == [True, False, False]
assert s.is_last_distinct().to_list() == [False, False, True]


def test_is_in_non_strict() -> None:
s = pl.Series([1, 2, 3, 4])
assert s.is_in([2, 2.5], strict=False).to_list() == [False, True, False, False]

0 comments on commit 0e775bb

Please sign in to comment.