@@ -30,6 +30,12 @@ def dtype(string_dtype_arguments):
30
30
return pd .StringDtype (storage = storage , na_value = na_value )
31
31
32
32
33
+ @pytest .fixture
34
+ def dtype2 (string_dtype_arguments2 ):
35
+ storage , na_value = string_dtype_arguments2
36
+ return pd .StringDtype (storage = storage , na_value = na_value )
37
+
38
+
33
39
@pytest .fixture
34
40
def cls (dtype ):
35
41
"""Fixture giving array type from parametrized 'dtype'"""
@@ -662,11 +668,7 @@ def test_isin(dtype, fixed_now_ts):
662
668
tm .assert_series_equal (result , expected )
663
669
664
670
result = s .isin (["a" , pd .NA ])
665
- if dtype .storage == "python" and dtype .na_value is np .nan :
666
- # TODO(infer_string) we should make this consistent
667
- expected = pd .Series ([True , False , False ])
668
- else :
669
- expected = pd .Series ([True , False , True ])
671
+ expected = pd .Series ([True , False , True ])
670
672
tm .assert_series_equal (result , expected )
671
673
672
674
result = s .isin ([])
@@ -677,6 +679,35 @@ def test_isin(dtype, fixed_now_ts):
677
679
expected = pd .Series ([True , False , False ])
678
680
tm .assert_series_equal (result , expected )
679
681
682
+ result = s .isin ([fixed_now_ts ])
683
+ expected = pd .Series ([False , False , False ])
684
+ tm .assert_series_equal (result , expected )
685
+
686
+
687
+ def test_isin_string_array (dtype , dtype2 ):
688
+ s = pd .Series (["a" , "b" , None ], dtype = dtype )
689
+
690
+ result = s .isin (pd .array (["a" , "c" ], dtype = dtype2 ))
691
+ expected = pd .Series ([True , False , False ])
692
+ tm .assert_series_equal (result , expected )
693
+
694
+ result = s .isin (pd .array (["a" , None ], dtype = dtype2 ))
695
+ expected = pd .Series ([True , False , True ])
696
+ tm .assert_series_equal (result , expected )
697
+
698
+
699
+ def test_isin_arrow_string_array (dtype ):
700
+ pa = pytest .importorskip ("pyarrow" )
701
+ s = pd .Series (["a" , "b" , None ], dtype = dtype )
702
+
703
+ result = s .isin (pd .array (["a" , "c" ], dtype = pd .ArrowDtype (pa .string ())))
704
+ expected = pd .Series ([True , False , False ])
705
+ tm .assert_series_equal (result , expected )
706
+
707
+ result = s .isin (pd .array (["a" , None ], dtype = pd .ArrowDtype (pa .string ())))
708
+ expected = pd .Series ([True , False , True ])
709
+ tm .assert_series_equal (result , expected )
710
+
680
711
681
712
def test_setitem_scalar_with_mask_validation (dtype ):
682
713
# https://github.com/pandas-dev/pandas/issues/47628
0 commit comments