@@ -1252,13 +1252,15 @@ def test_bad_date_parse(all_parsers, cache_dates, value):
1252
1252
parser = all_parsers
1253
1253
s = StringIO ((f"{ value } ,\n " ) * 50000 )
1254
1254
1255
- if parser .engine == "pyarrow" :
1255
+ if parser .engine == "pyarrow" and not cache_dates :
1256
1256
# None in input gets converted to 'None', for which
1257
1257
# pandas tries to guess the datetime format, triggering
1258
1258
# the warning. TODO: parse dates directly in pyarrow, see
1259
1259
# https://github.com/pandas-dev/pandas/issues/48017
1260
1260
warn = UserWarning
1261
1261
else :
1262
+ # Note: warning is not raised if 'cache_dates', because here there is only a
1263
+ # single unique date and hence no risk of inconsistent parsing.
1262
1264
warn = None
1263
1265
parser .read_csv_check_warnings (
1264
1266
warn ,
@@ -1285,6 +1287,10 @@ def test_bad_date_parse_with_warning(all_parsers, cache_dates, value):
1285
1287
# TODO: parse dates directly in pyarrow, see
1286
1288
# https://github.com/pandas-dev/pandas/issues/48017
1287
1289
warn = None
1290
+ elif cache_dates :
1291
+ # Note: warning is not raised if 'cache_dates', because here there is only a
1292
+ # single unique date and hence no risk of inconsistent parsing.
1293
+ warn = None
1288
1294
else :
1289
1295
warn = UserWarning
1290
1296
parser .read_csv_check_warnings (
@@ -1737,9 +1743,7 @@ def test_parse_timezone(all_parsers):
1737
1743
def test_invalid_parse_delimited_date (all_parsers , date_string ):
1738
1744
parser = all_parsers
1739
1745
expected = DataFrame ({0 : [date_string ]}, dtype = "object" )
1740
- result = parser .read_csv_check_warnings (
1741
- UserWarning ,
1742
- "Could not infer format" ,
1746
+ result = parser .read_csv (
1743
1747
StringIO (date_string ),
1744
1748
header = None ,
1745
1749
parse_dates = [0 ],
@@ -2063,9 +2067,7 @@ def test_infer_first_column_as_index(all_parsers):
2063
2067
# GH#11019
2064
2068
parser = all_parsers
2065
2069
data = "a,b,c\n 1970-01-01,2,3,4"
2066
- result = parser .read_csv_check_warnings (
2067
- UserWarning ,
2068
- "Could not infer format" ,
2070
+ result = parser .read_csv (
2069
2071
StringIO (data ),
2070
2072
parse_dates = ["a" ],
2071
2073
)
0 commit comments