@@ -29,6 +29,12 @@ def dtype(string_dtype_arguments):
29
29
return pd .StringDtype (storage = storage , na_value = na_value )
30
30
31
31
32
+ @pytest .fixture
33
+ def dtype2 (string_dtype_arguments2 ):
34
+ storage , na_value = string_dtype_arguments2
35
+ return pd .StringDtype (storage = storage , na_value = na_value )
36
+
37
+
32
38
@pytest .fixture
33
39
def cls (dtype ):
34
40
"""Fixture giving array type from parametrized 'dtype'"""
@@ -689,11 +695,7 @@ def test_isin(dtype, fixed_now_ts):
689
695
tm .assert_series_equal (result , expected )
690
696
691
697
result = s .isin (["a" , pd .NA ])
692
- if dtype .storage == "python" and dtype .na_value is np .nan :
693
- # TODO(infer_string) we should make this consistent
694
- expected = pd .Series ([True , False , False ])
695
- else :
696
- expected = pd .Series ([True , False , True ])
698
+ expected = pd .Series ([True , False , True ])
697
699
tm .assert_series_equal (result , expected )
698
700
699
701
result = s .isin ([])
@@ -704,6 +706,35 @@ def test_isin(dtype, fixed_now_ts):
704
706
expected = pd .Series ([True , False , False ])
705
707
tm .assert_series_equal (result , expected )
706
708
709
+ result = s .isin ([fixed_now_ts ])
710
+ expected = pd .Series ([False , False , False ])
711
+ tm .assert_series_equal (result , expected )
712
+
713
+
714
+ def test_isin_string_array (dtype , dtype2 ):
715
+ s = pd .Series (["a" , "b" , None ], dtype = dtype )
716
+
717
+ result = s .isin (pd .array (["a" , "c" ], dtype = dtype2 ))
718
+ expected = pd .Series ([True , False , False ])
719
+ tm .assert_series_equal (result , expected )
720
+
721
+ result = s .isin (pd .array (["a" , None ], dtype = dtype2 ))
722
+ expected = pd .Series ([True , False , True ])
723
+ tm .assert_series_equal (result , expected )
724
+
725
+
726
+ def test_isin_arrow_string_array (dtype ):
727
+ pa = pytest .importorskip ("pyarrow" )
728
+ s = pd .Series (["a" , "b" , None ], dtype = dtype )
729
+
730
+ result = s .isin (pd .array (["a" , "c" ], dtype = pd .ArrowDtype (pa .string ())))
731
+ expected = pd .Series ([True , False , False ])
732
+ tm .assert_series_equal (result , expected )
733
+
734
+ result = s .isin (pd .array (["a" , None ], dtype = pd .ArrowDtype (pa .string ())))
735
+ expected = pd .Series ([True , False , True ])
736
+ tm .assert_series_equal (result , expected )
737
+
707
738
708
739
def test_setitem_scalar_with_mask_validation (dtype ):
709
740
# https://github.com/pandas-dev/pandas/issues/47628
0 commit comments