Skip to content

BUG: to_parquet set schema metadata to datetime64 instead of datetime64[us] when dtype of the column is datetime64[us] #55118

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

Open
2 of 3 tasks
xythu opened this issue Sep 13, 2023 · 1 comment
Labels
Bug IO Parquet parquet, feather

Comments

@xythu
Copy link

xythu commented Sep 13, 2023

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 pandas as pd

a = pd.DataFrame([1, 2, 3])
a.columns = a.columns.astype('datetime64[us]')
a.to_parquet('t.parquet')
# TypeError: Casting to unit-less dtype 'datetime64' is not supported. Pass e.g. 'datetime64[ns]' instead.
pd.read_parquet('t.parquet')

Issue Description

to_parquet generate incorrect schema metadata when using datetime64[us] as column dtype. As a result, read_parquet raise TypeError.

copy from pyarrow by pq.read_schema('t.parquet').metadata

"column_indexes": [{"name": null, "field_name": null, "pandas_type": "datetime64", "numpy_type": "datetime64[us]",...

Expected Behavior

pandas_type should be datetime64[us] not datetime64 in the schema metadata

Installed Versions

INSTALLED VERSIONS

commit : ba1cccd
python : 3.10.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-153-generic
Version : #170-Ubuntu SMP Fri Jun 16 13:43:31 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.1.0
numpy : 1.25.2
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 23.2.1
Cython : 3.0.0
pytest : 7.4.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.15.0
pandas_datareader : 0.10.0
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : 2023.6.0
gcsfs : None
matplotlib : 3.7.2
numba : None
numexpr : 2.8.6
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.2
sqlalchemy : 2.0.18
tables : 3.8.0
tabulate : 0.9.0
xarray : 2023.7.0
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@xythu xythu added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 13, 2023
@xythu xythu changed the title BUG: to_parquet set schema metadata to datetime64 instead of datetime64[ns] when dtype of the column is `datetime64[us]' BUG: to_parquet set schema metadata to datetime64 instead of datetime64[us] when dtype of the column is `datetime64[us]' Sep 13, 2023
@xythu xythu changed the title BUG: to_parquet set schema metadata to datetime64 instead of datetime64[us] when dtype of the column is `datetime64[us]' BUG: to_parquet set schema metadata to datetime64 instead of datetime64[us] when dtype of the column is datetime64[us] Sep 13, 2023
@jorisvandenbossche jorisvandenbossche added the IO Parquet parquet, feather label Oct 27, 2023
@rhshadrach
Copy link
Member

I'm now seeing datetime64[us] on main, could likely use a test.

@rhshadrach rhshadrach removed the Needs Triage Issue that has not been reviewed by a pandas team member label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Parquet parquet, feather
Projects
None yet
Development

No branches or pull requests

3 participants