Skip to content

Commit 63d3971

Browse files
authored
TST: Add test for pd.read_csv date parsing not working with dtype_backend="pyarrow" and missing values (#60286)
* add test func * remove io since StringIO is already imported * add td.skip_if_no("pyarrow") from CI errors * fix test * improve expect_data; remove assert on "date" column dtype
1 parent 3895156 commit 63d3971

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/io/test_common.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,3 +671,17 @@ def test_pickle_reader(reader):
671671
# GH 22265
672672
with BytesIO() as buffer:
673673
pickle.dump(reader, buffer)
674+
675+
676+
@td.skip_if_no("pyarrow")
677+
def test_pyarrow_read_csv_datetime_dtype():
678+
# GH 59904
679+
data = '"date"\n"20/12/2025"\n""\n"31/12/2020"'
680+
result = pd.read_csv(
681+
StringIO(data), parse_dates=["date"], dayfirst=True, dtype_backend="pyarrow"
682+
)
683+
684+
expect_data = pd.to_datetime(["20/12/2025", pd.NaT, "31/12/2020"], dayfirst=True)
685+
expect = pd.DataFrame({"date": expect_data})
686+
687+
tm.assert_frame_equal(expect, result)

0 commit comments

Comments
 (0)