@@ -1098,42 +1098,35 @@ def test_convert_object_to_datetime_with_cache(
1098
1098
1099
1099
@pytest .mark .parametrize ("cache" , [True , False ])
1100
1100
@pytest .mark .parametrize (
1101
- ("input" , "expected" , "warning" ),
1101
+ ("input" , "expected" ),
1102
1102
(
1103
1103
(
1104
1104
Series ([NaT ] * 20 + [None ] * 20 , dtype = "object" ),
1105
1105
Series ([NaT ] * 40 , dtype = "datetime64[ns]" ),
1106
- None ,
1107
1106
),
1108
1107
(
1109
1108
Series ([NaT ] * 60 + [None ] * 60 , dtype = "object" ),
1110
1109
Series ([NaT ] * 120 , dtype = "datetime64[ns]" ),
1111
- None ,
1112
1110
),
1113
- (Series ([None ] * 20 ), Series ([NaT ] * 20 , dtype = "datetime64[ns]" ), None ),
1114
- (Series ([None ] * 60 ), Series ([NaT ] * 60 , dtype = "datetime64[ns]" ), None ),
1111
+ (Series ([None ] * 20 ), Series ([NaT ] * 20 , dtype = "datetime64[ns]" )),
1112
+ (Series ([None ] * 60 ), Series ([NaT ] * 60 , dtype = "datetime64[ns]" )),
1115
1113
(
1116
1114
Series (["" ] * 20 ),
1117
1115
Series ([NaT ] * 20 , dtype = "datetime64[ns]" ),
1118
- UserWarning ,
1119
1116
),
1120
1117
(
1121
1118
Series (["" ] * 60 ),
1122
1119
Series ([NaT ] * 60 , dtype = "datetime64[ns]" ),
1123
- UserWarning ,
1124
1120
),
1125
- (Series ([pd .NA ] * 20 ), Series ([NaT ] * 20 , dtype = "datetime64[ns]" ), None ),
1126
- (Series ([pd .NA ] * 60 ), Series ([NaT ] * 60 , dtype = "datetime64[ns]" ), None ),
1127
- (Series ([np .NaN ] * 20 ), Series ([NaT ] * 20 , dtype = "datetime64[ns]" ), None ),
1128
- (Series ([np .NaN ] * 60 ), Series ([NaT ] * 60 , dtype = "datetime64[ns]" ), None ),
1121
+ (Series ([pd .NA ] * 20 ), Series ([NaT ] * 20 , dtype = "datetime64[ns]" )),
1122
+ (Series ([pd .NA ] * 60 ), Series ([NaT ] * 60 , dtype = "datetime64[ns]" )),
1123
+ (Series ([np .NaN ] * 20 ), Series ([NaT ] * 20 , dtype = "datetime64[ns]" )),
1124
+ (Series ([np .NaN ] * 60 ), Series ([NaT ] * 60 , dtype = "datetime64[ns]" )),
1129
1125
),
1130
1126
)
1131
- def test_to_datetime_converts_null_like_to_nat (
1132
- self , cache , input , expected , warning
1133
- ):
1127
+ def test_to_datetime_converts_null_like_to_nat (self , cache , input , expected ):
1134
1128
# GH35888
1135
- with tm .assert_produces_warning (warning , match = "Could not infer format" ):
1136
- result = to_datetime (input , cache = cache )
1129
+ result = to_datetime (input , cache = cache )
1137
1130
tm .assert_series_equal (result , expected )
1138
1131
1139
1132
@pytest .mark .parametrize (
@@ -1286,8 +1279,7 @@ def test_mixed_offsets_with_native_datetime_raises(self):
1286
1279
ser = Series (vals )
1287
1280
assert all (ser [i ] is vals [i ] for i in range (len (vals ))) # GH#40111
1288
1281
1289
- with tm .assert_produces_warning (UserWarning , match = "Could not infer format" ):
1290
- mixed = to_datetime (ser )
1282
+ mixed = to_datetime (ser )
1291
1283
expected = Series (
1292
1284
[
1293
1285
"NaT" ,
@@ -1849,13 +1841,11 @@ def test_to_datetime_with_apply_with_empty_str(self, cache):
1849
1841
1850
1842
def test_to_datetime_empty_stt (self , cache ):
1851
1843
# empty string
1852
- with tm .assert_produces_warning (UserWarning , match = "Could not infer format" ):
1853
- result = to_datetime ("" , cache = cache )
1844
+ result = to_datetime ("" , cache = cache )
1854
1845
assert result is NaT
1855
1846
1856
1847
def test_to_datetime_empty_str_list (self , cache ):
1857
- with tm .assert_produces_warning (UserWarning , match = "Could not infer format" ):
1858
- result = to_datetime (["" , "" ], cache = cache )
1848
+ result = to_datetime (["" , "" ], cache = cache )
1859
1849
assert isna (result ).all ()
1860
1850
1861
1851
def test_to_datetime_zero (self , cache ):
@@ -2340,8 +2330,7 @@ def test_na_values_with_cache(
2340
2330
def test_parsers_nat (self ):
2341
2331
# Test that each of several string-accepting methods return pd.NaT
2342
2332
result1 , _ = parsing .parse_time_string ("NaT" )
2343
- with tm .assert_produces_warning (UserWarning , match = "Could not infer format" ):
2344
- result2 = to_datetime ("NaT" )
2333
+ result2 = to_datetime ("NaT" )
2345
2334
result3 = Timestamp ("NaT" )
2346
2335
result4 = DatetimeIndex (["NaT" ])[0 ]
2347
2336
assert result1 is NaT
0 commit comments