Skip to content

read_excel drops columns when reading a one row file with a MultiIndex #9208

Closed
@maxgrenderjones

Description

@maxgrenderjones

I'm seeing the weirdest error.

When I read an .xlsx excel file with only one row (example below)...
image
... and try to set the index_col, then pandas incorrectly reads the columns:

I.e. for a file with only one row, column headers A, B, C, D, E, F

pandas.read_excel(filename, 'Sheet1', index_col=['A', 'B', 'C'])

Yields
image
(I get an index with columns A, B, C, and a dataframe with columns B, D, F - what happened to E?)

Note that if I don't use index_col, I get a dataframe with columns A-F as expected. Likewise, if I add a row of actual data, the dataframe loads as expected.

Relevant versions:
pandas version 0.15.1 running on 2.7.7 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 10:40:02) [MSC v.1500 64 bit (AMD64)]
xlrd.__VERSION__=0.9.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO DataIO issues that don't fit into a more specific labelIO Excelread_excel, to_excel

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions