File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 1414 is_compliant_series ,
1515 is_eager_allowed ,
1616 is_index_selector ,
17+ iterable_to_sequence ,
1718 qualified_type_name ,
1819 supports_arrow_c_stream ,
1920)
2526from narwhals .series_list import SeriesListNamespace
2627from narwhals .series_str import SeriesStringNamespace
2728from narwhals .series_struct import SeriesStructNamespace
28- from narwhals .translate import to_native
2929from narwhals .typing import IntoSeriesT
3030
3131if TYPE_CHECKING :
@@ -948,9 +948,12 @@ def is_in(self, other: Any) -> Self:
948948 ]
949949 ]
950950 """
951- return self ._with_compliant (
952- self ._compliant_series .is_in (to_native (other , pass_through = True ))
951+ other = (
952+ other .to_native ()
953+ if isinstance (other , Series )
954+ else iterable_to_sequence (other , backend = self .implementation )
953955 )
956+ return self ._with_compliant (self ._compliant_series .is_in (other ))
954957
955958 def arg_true (self ) -> Self :
956959 """Find elements where boolean Series is True.
Original file line number Diff line number Diff line change @@ -67,10 +67,21 @@ def test_filter_is_in_with_series(constructor_eager: ConstructorEager) -> None:
6767
6868
6969def test_ser_is_in_iterable (
70- constructor_eager : ConstructorEager , into_iter_16 : IntoIterable
70+ constructor_eager : ConstructorEager ,
71+ into_iter_16 : IntoIterable ,
72+ request : pytest .FixtureRequest ,
7173) -> None :
72- ser = nw .from_native (constructor_eager (data )).get_column ("a" )
74+ test_name = request .node .name
75+ # NOTE: This *could* be supported by using `ExtensionArray.tolist` (same path as numpy)
76+ request .applymarker (
77+ pytest .mark .xfail (
78+ ("polars" in test_name and "pandas" in test_name and "array" in test_name ),
79+ raises = TypeError ,
80+ reason = "Polars doesn't support `pd.array`.\n https://github.com/pola-rs/polars/issues/22757" ,
81+ )
82+ )
7383 iterable = into_iter_16 ((4 , 2 ))
84+ ser = nw .from_native (constructor_eager (data )).get_column ("a" )
7485 result = ser .is_in (iterable )
7586 expected = [False , True , True , False ]
7687 assert_equal_series (result , expected , "a" )
You can’t perform that action at this time.
0 commit comments