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

Comments

Projects
None yet
4 participants
@maxgrenderjones
Copy link
Contributor

commented Jan 7, 2015

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

This comment has been minimized.

Copy link
Member

commented Jan 8, 2015

I can confirm this with 0.15.2

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015

@maxgrenderjones

This comment has been minimized.

Copy link
Contributor Author

commented Jun 15, 2015

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

gfyoung added a commit that referenced this issue Nov 13, 2018

JustinZhengBC added 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 added a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019

Pingviinituutti added 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
You can’t perform that action at this time.