@@ -43,6 +43,33 @@ def test_isin_with_string_scalar(self):
43
43
with pytest .raises (TypeError , match = msg ):
44
44
s .isin ("aaa" )
45
45
46
+ def test_isin_datetimelike_mismatched_reso (self ):
47
+ expected = Series ([True , True , False , False , False ])
48
+
49
+ ser = Series (date_range ("jan-01-2013" , "jan-05-2013" ))
50
+
51
+ # fails on dtype conversion in the first place
52
+ day_values = np .asarray (ser [0 :2 ].values ).astype ("datetime64[D]" )
53
+ result = ser .isin (day_values )
54
+ tm .assert_series_equal (result , expected )
55
+
56
+ dta = ser [:2 ]._values .astype ("M8[s]" )
57
+ result = ser .isin (dta )
58
+ tm .assert_series_equal (result , expected )
59
+
60
+ @pytest .mark .xfail (
61
+ reason = "DTA._from_sequence incorrectly treats Timestamp[s].value as "
62
+ "nanoseconds."
63
+ )
64
+ def test_isin_datetimelike_mismatched_reso_list (self ):
65
+ expected = Series ([True , True , False , False , False ])
66
+
67
+ ser = Series (date_range ("jan-01-2013" , "jan-05-2013" ))
68
+
69
+ dta = ser [:2 ]._values .astype ("M8[s]" )
70
+ result = ser .isin (list (dta ))
71
+ tm .assert_series_equal (result , expected )
72
+
46
73
def test_isin_with_i8 (self ):
47
74
# GH#5021
48
75
@@ -58,10 +85,6 @@ def test_isin_with_i8(self):
58
85
result = s .isin (s [0 :2 ].values )
59
86
tm .assert_series_equal (result , expected )
60
87
61
- # fails on dtype conversion in the first place
62
- result = s .isin (np .asarray (s [0 :2 ].values ).astype ("datetime64[D]" ))
63
- tm .assert_series_equal (result , expected )
64
-
65
88
result = s .isin ([s [1 ]])
66
89
tm .assert_series_equal (result , expected2 )
67
90
0 commit comments