Skip to content

Commit

Permalink
TST: Add test for pd.read_csv date parsing not working with `dtype_…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
KevsterAmp authored Nov 15, 2024
1 parent 3895156 commit 63d3971
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pandas/tests/io/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,3 +671,17 @@ def test_pickle_reader(reader):
# GH 22265
with BytesIO() as buffer:
pickle.dump(reader, buffer)


@td.skip_if_no("pyarrow")
def test_pyarrow_read_csv_datetime_dtype():
# GH 59904
data = '"date"\n"20/12/2025"\n""\n"31/12/2020"'
result = pd.read_csv(
StringIO(data), parse_dates=["date"], dayfirst=True, dtype_backend="pyarrow"
)

expect_data = pd.to_datetime(["20/12/2025", pd.NaT, "31/12/2020"], dayfirst=True)
expect = pd.DataFrame({"date": expect_data})

tm.assert_frame_equal(expect, result)

0 comments on commit 63d3971

Please sign in to comment.