Description
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