-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
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
import io
data = """datetime,id
2023-12-31 12:34:56,a
2000-01-01 01:23:45,b
"""
df0 = pd.read_csv(io.StringIO(data), parse_dates=["datetime"])
df0.dtypes
# datetime datetime64[ns]
# id object
# dtype: object
df0.convert_dtypes(dtype_backend="pyarrow").dtypes
# datetime timestamp[ns][pyarrow]
# id string[pyarrow]
# dtype: object
df1 = pd.read_csv(io.StringIO(data), parse_dates=["datetime"], dtype_backend="pyarrow")
df1.dtypes
# datetime datetime64[ns]
# id string[pyarrow]
# dtype: objectIssue Description
I'm uncertain whether this is a bug or intentional design.
On pandas 2.1.1, when utilizing read_csv(..., dtype_backend="pyarrow"), a column specified in parse_dates returns a datetime64[ns] type, whereas I expect a timestamp[ns][pyarrow] type, as indicated by the results of .convert_dtypes(dtype_backend="pyarrow").
Thanks,
Expected Behavior
df1.dtypes
# datetime timestamp[ns][pyarrow]
# id string[pyarrow]
# dtype: objectInstalled Versions
$ docker run -it --rm python:3.11.6-slim bash
root@2eff93196ac4:/# pip install -U pip & pip install pandas==2.1.1 & pip install pyarrow==13.0.0
root@2eff93196ac4:/# python
>>> pd.show_versions()
/usr/local/lib/python3.11/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
INSTALLED VERSIONS
commit : e86ed37
python : 3.11.6.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.49-linuxkit-pr
Version : #1 SMP Thu May 25 07:17:40 UTC 2023
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.1
numpy : 1.26.0
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 65.5.1
pip : 23.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None