Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Add test for pd.read_csv date parsing not working with dtype_backend="pyarrow" and missing values #60286

16 changes: 16 additions & 0 deletions pandas/tests/io/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,3 +674,19 @@ 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.Series(
pd.to_datetime(["20/12/2025", pd.NaT, "31/12/2020"], dayfirst=True)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect_data = pd.Series(
pd.to_datetime(["20/12/2025", pd.NaT, "31/12/2020"], dayfirst=True)
)
expect_data = pd.to_datetime(["20/12/2025", pd.NaT, "31/12/2020"], dayfirst=True)

expect = pd.DataFrame({"date": expect_data})

assert (result["date"].dtype) == "datetime64[s]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert (result["date"].dtype) == "datetime64[s]"

This is done in assert_frame_equal

tm.assert_frame_equal(expect, result)