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

BUG: pd.read_csv date parsing not working with dtype_backend="pyarrow" and missing values #59904

Closed
2 of 3 tasks
mhabets opened this issue Sep 26, 2024 · 12 comments · Fixed by #60286
Closed
2 of 3 tasks
Assignees
Labels
Arrow pyarrow functionality Bug good first issue IO CSV read_csv, to_csv Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Needs Tests Unit test(s) needed to prevent regressions

Comments

@mhabets
Copy link

mhabets commented Sep 26, 2024

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import io

data = """date,id
20/12/2025,a
,b
31/12/2020,c
"""
df = pd.read_csv(io.StringIO(data), parse_dates=["date"], dayfirst=True, dtype_backend="pyarrow")
df.dtypes
# date        string[pyarrow_numpy]
# id          large_string[pyarrow]

Issue Description

dtype for the date column is not a date dtype as a result of a date parsing failure because of the missing value on the second row

Expected Behavior

dtype for the date column should be timestamp[ns][pyarrow]

Installed Versions

INSTALLED VERSIONS

commit : d9cdd2e
python : 3.12.5.final.0
python-bits : 64
OS : Windows
OS-release : 11
Version : 10.0.22631
machine : AMD64
processor : Intel64 Family 6 Model 154 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en
LOCALE : English_United Kingdom.1252

pandas : 2.2.2
numpy : 2.0.1
pytz : 2024.1
dateutil : 2.9.0
setuptools : 72.1.0
pip : 24.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 5.3.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.26.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.9.2
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.5
pandas_gbq : None
pyarrow : 17.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.14.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 2.0.1
zstandard : 0.23.0
tzdata : 2024.1
qtpy : None
pyqt5 : None

@mhabets mhabets added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 26, 2024
@yuanx749
Copy link
Contributor

It seems on main branch, df.dtypes are

date      datetime64[s]
id      string[pyarrow]

@rhshadrach
Copy link
Member

Thanks for the report. As @yuanx749 mentioned, it appears this is already fixed on the main branch. We should run a git bisect to see what PR fixed this in order to determine whether tests need to be added.

@rhshadrach rhshadrach added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate IO CSV read_csv, to_csv Arrow pyarrow functionality labels Sep 30, 2024
@rhshadrach
Copy link
Member

A git bisect points at #58622 fixing this. From what I can tell, I don't think that was intentional and could use a test.

cc @mroeschke

@rhshadrach rhshadrach added Needs Tests Unit test(s) needed to prevent regressions good first issue and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 1, 2024
@wshaoul
Copy link

wshaoul commented Oct 4, 2024

take

@kukuruzka kukuruzka removed their assignment Oct 4, 2024
@tohfas
Copy link

tohfas commented Oct 9, 2024

Hi, I am looking for this issue for my university assignment. Can this issue be assigned to me? Please let me know. Thanks.

@sunlight798
Copy link
Contributor

Hello, i am new contributor in pandas, can i work on this issue? Thanks

@bcxpro
Copy link

bcxpro commented Oct 9, 2024

A git bisect points at #58622 fixing this. From what I can tell, I don't think that was intentional and could use a test.

cc @mroeschke

I had not seen your post and I also run a bisect with the same conclusion.

For tag v2.2.3

date             object
id      string[pyarrow]

After a17d449:

date     datetime64[ns]
id      string[pyarrow]

@KevsterAmp
Copy link
Contributor

@Lavishgangwani are you still working on this? I'd like to take on this issue. thanks

@Lavishgangwani
Copy link

You can take it... Brother @KevsterAmp

@KevsterAmp
Copy link
Contributor

Thanks @Lavishgangwani!

@KevsterAmp
Copy link
Contributor

take

1 similar comment
@KevsterAmp
Copy link
Contributor

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Bug good first issue IO CSV read_csv, to_csv Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
10 participants