Skip to content
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

Give more precise warning when passing `header=-1` in `pandas.read_csv`, or don't throw error #27779

Closed
MarcoGorelli opened this issue Aug 6, 2019 · 3 comments · Fixed by #27878

Comments

@MarcoGorelli
Copy link
Contributor

commented Aug 6, 2019

Code Sample, a copy-pastable example if possible

from io import StringIO
import pandas as pd

print(f"Using pandas version {pd.__version__}")
pd.read_csv(StringIO('spam'), header=-1)

Using pandas version 0.25.0


OverflowError

Problem description

In previous versions of pandas (e.g. 0.24.2), this would have worked fine. Instead, now, one has to pass header=None. However, when working with old code after having updated pandas, it may be unclear where the problem lies.

Expected Output

      0
0  spam

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit : None
python : 3.7.3.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-55-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 0.25.0
numpy : 1.16.4
pytz : 2019.1
dateutil : 2.8.0
pip : 19.1.1
setuptools : 41.0.1
Cython : 0.29.12
pytest : 4.5.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.7.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.13.0
pytables : None
s3fs : 0.2.1
scipy : 1.3.0
sqlalchemy : 1.3.5
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None

@MarcoGorelli MarcoGorelli changed the title Give more precise warning when passing `header=-1` in `pandas.read_csv` Give more precise warning when passing `header=-1` in `pandas.read_csv`, or don't throw error Aug 6, 2019

@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Aug 9, 2019

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented Aug 9, 2019

@MarcoGorelli are you interested in submitting a pull request?

@MarcoGorelli

This comment has been minimized.

Copy link
Contributor Author

commented Aug 9, 2019

@MarcoGorelli

This comment has been minimized.

Copy link
Contributor Author

commented Aug 14, 2019

I've attempted to fix this by modifying validate_header from pandas/io/common.py to check that header=-1 wasn't passed and to raise an error advising user to pass header=None instead if their data has no header, along with an accompanying test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.