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

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

Closed
maxgrenderjones opened this issue Jan 7, 2015 · 2 comments
Closed
Labels
Bug IO Data IO issues that don't fit into a more specific label IO Excel read_excel, to_excel
Milestone

Comments

@maxgrenderjones
Copy link
Contributor

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

@jorisvandenbossche jorisvandenbossche added Bug IO Data IO issues that don't fit into a more specific label IO Excel read_excel, to_excel labels Jan 8, 2015
@jorisvandenbossche jorisvandenbossche added this to the 0.16.0 milestone Jan 8, 2015
@jorisvandenbossche
Copy link
Member

I can confirm this with 0.15.2

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@maxgrenderjones
Copy link
Contributor Author

Would have to dig into it (unlikely to have time soon), but #10184 might suggest how this could be fixed, as the issues seem similar.

gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 13, 2018
JustinZhengBC pushed a commit to JustinZhengBC/pandas that referenced this issue Nov 14, 2018
@gfyoung gfyoung modified the milestones: Contributions Welcome, 0.24.0 Nov 14, 2018
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Data IO issues that don't fit into a more specific label IO Excel read_excel, to_excel
Projects
None yet
Development

No branches or pull requests

4 participants