-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pandas.read_excel index_col argument behavior seems to be wrong (or unexpected, as by the docs) #16582
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
Comments
Can you make a reproducible example? I tried this out (see below) and it seems to be working ok? df = pd.DataFrame(columns=list('ABCDEFGHIJKL'), data=np.zeros((100, 12)))
df.to_excel('tmp.xlsx', index=False)
pd.read_excel('tmp.xlsx').head()
Out[6]:
A B C D E F G H I J K L
0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0 0 0 0
In [9]: pd.read_excel('tmp.xlsx', parse_cols='D:J', index_col=0).head()
Out[9]:
E F G H I J
D
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 |
Well, thanks, That's what I meant, actually. I expected the index_col int to match some column in the original document, as it is not precised. Maybe I missed something in the docs, though, about this kind of parsing things. So it is expected to work like this? Sorry for disturbing, then. |
Oh I see, I misread that. Yeah, in general it seems like we make
|
@chris-b1 Can you help me figure out where to get started with fixing this issue? I understand the issue, just need the code guidance a bit. |
I'd expand the explanation of Line 85 in 697d026
And them maybe add an example to the narrative docs, somewhere around here (by changing this file): |
@chris-b1 So we need not make changes in the code to allow the exception? |
Right, the current behavior is intended, this is only a documentation issue.
…On Tue, Jun 6, 2017 at 9:49 AM, Rosy Gupta ***@***.***> wrote:
@chris-b1 <https://github.com/chris-b1> So we need not make changes in
the code to allow the exception?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16582 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB1b_EVMy7uaY4NRVXDX7-tF7bYHDFGiks5sBWcEgaJpZM4NuGX8>
.
|
@chris-b1 I shall work on it. But I'm more interested in some coding issue. Could you suggest some for starters? |
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_excel.html#pandas.read_excel
It's about the parameter index_col.
From the docs, I read
I use the function with args={index_col=3, parse_cols="D-J"} (so it should parse from column 3 to column 9 included, 0-indexed). And I expected D to be used as Index, but actually it was column G.
I am not sure if it is the expected behavior, if then, maybe argument order should be changed to show that index_col depends on parsed_cols.
The text was updated successfully, but these errors were encountered: