Code Sample

If test.csv file looks like:

a,b,c
0,1,2
1,2,3

Reading in the file with the header given in a list of length 0 results in no warnings or errors, but each line is interpreted as NaNs.

>>> import pandas as pd
>>> pd.read_csv("test.csv", header=[0])
      a     b     c
0   NaN   NaN   NaN
1   NaN   NaN   NaN

Problem description

Single-length lists are not a problem elsewhere in pandas or within read_csv. For example, passing index_col=[0] does not cause pandas to read a csv file incorrectly. Preferably pandas would read in the csv file correctly given a list of header rows with one element. Raising an error or warning would also be an improvement over the current functionality.

Expected Output

>>> import pandas as pd
>>> pd.read_csv("test.csv", header=[0])
    a   b   c
0   0   1   2
1   1   2   3

Output of pd.show_versions()

OS: macOS Sierra Python: 2.7.13 pandas: 0.20.2 pytest: None pip: 9.0.1 setuptools: 27.2.0 Cython: 0.25.2 numpy: 1.13.1 scipy: 0.19.1 xarray: None IPython: 5.3.0 sphinx: None patsy: 0.4.1 dateutil: 2.6.0 pytz: 2017.2 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: 2.0.2 openpyxl: None xlrd: None xlwt: None xlsxwriter: None lxml: None bs4: None html5lib: 0.999 sqlalchemy: None pymysql: None psycopg2: None jinja2: 2.9.6 s3fs: None pandas_gbq: None pandas_datareader: None

Comment From: chris-b1

Thanks - duplicate of #7757, agree this is surprising!

Comment From: gfyoung

Because logic: passing in header=[0, 1] has no issues. :cry: