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: read_csv converts quoted strings to floats with quoting=csv.QUOTE_NONNUMERIC #35713
Comments
I've confirmed this is a pandas bug, not a csv bug. import csv
import io
source = io.StringIO('"col"\n"1"')
reader = csv.reader(source, quoting=csv.QUOTE_NONNUMERIC)
rows = [r for r in reader]
assert rows[1] == ['1'] |
Hi @simonjayhawkins |
Thanks @rmsmani the contributing docs are here https://pandas.pydata.org/docs/dev/development/contributing.html |
Is there any update on this bug? I am hitting it in a very weird way: specifically the string import pandas as pd
import io
source = io.StringIO('"col"\n"Some"\n"None"\n"All"')
df = pd.read_csv(source)
print(df) gives the output:
So the |
@psybers
Now in pandas > 2, all bugs related to csv reading can be avoided if you know the types in advance. Then you use the If you want to force strings in your example :
|
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.
Code Sample, a copy-pastable example
Problem description
In the documentation of
csv.QUOTE_NONNUMERIC
, it says:Yet
pandas.read_csv
is converting my quoted value into a float. The above test case fails.Expected Output
The code sample should pass the assertion.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : d9fff27
python : 3.8.3.final.0
python-bits : 64
OS : Darwin
OS-release : 18.7.0
Version : Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.0
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.2
setuptools : 46.0.0
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 : 7.16.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: