-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: ValueError in read_csv when dtype='string' and parse_dates is present #34066
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
Comments
@meownoid The string Dtype was added in 1.0.0, see #27949. Can you check the versions used for the working case. I'm getting ...
|
@simonjayhawkins Sorry for confusion, in 0.25.3 worked alternative version of this code with the dtype="str": pd.read_csv("test.csv", dtype="str", parse_dates=["b"]) |
Thanks @meownoid for the clarification. will update title. |
This bug still stands and the copy-paste-able example still works. If I get up the motivation I might jump in as a contributor and fix it. In the meanwhile, a workaround is to not use the "dtype" keyword. The default actions of pd.read_csv tend to work pretty well. If they don't, you can clean up the dtypes after reading. |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
ValueError: not all elements from date_cols are numpy arrays
Expected Output
Data frame with all columns as strings except ones specified in parse_dates optional argument.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.8.1.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-22-generic
machine : x86_64
processor :
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : None.None
pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 46.1.3
Cython : 0.29.15
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : None
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : 2.11.2
IPython : 7.13.0
pandas_datareader: None
bs4 : 4.9.0
bottleneck : 1.3.2
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.16.0
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : 0.48.0
The text was updated successfully, but these errors were encountered: