-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: parser can handle a common_format multi-column index (no row index cols), (GH4702) #5298
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
Conversation
This is great! What is the expected behavior if first column has a label in |
that is the example that is up there |
@jreback your example starts out with a comma, so doesn't that mean the cell in the first two rows first column is empty? |
@jtratner I put another example up, no index col specified |
@jtratner what you were looking for? |
I'm guessing this works, but I mean ambiguous-ish cases: In [1]: data = """a,a,a,b,c,c
...: q,r,s,t,u,v
...: 1,2,3,4,5,6
...: 7,8,9,10,11,12"""
read_csv(StringIO(data),header=[0,1],index_col=0) What should this do? Raise? Assume that a and q are labels for MI levels? Similar question here In [1]: data = """,a,a,b,c,c
...: q,r,s,t,u,v
...: 1,2,3,4,5,6
...: 7,8,9,10,11,12"""
read_csv(StringIO(data),header=[0,1],index_col=0) (it takes my old mac a long time to compile, so I'm trying to pull down your branch now). And similarly what happens with MI header and MI index - 😄 In [1]: data = """,a,a,b,c,c
...: q,r,s,t,u,v
...: 1,2,3,4,5,6
...: 7,8,9,10,11,12"""
read_csv(StringIO(data),header=[0,1],index_col=[0, 1]) |
@jtratner your examples First one is user error
2nd is user error, but the data is corrupt (missing first label in top-level).
3rd works fine (its wrong specification, but could be valid)
|
The second one is what you'd expect from something with two level
|
@jtratner I think the 2nd one is exactly what you got, 2-level column mi, and 1-level index named q. maybe not what the user expects, but it parses correctly according tot he rules. |
Okay yeah that's what I'd expect. I was confused because you called it +1 to this! |
ok...I mean malformed as in possibly not what the user expects |
…ex cols), (GH4702) TST: addtl mi malformed test cases DOC: update io.rst docs for multi-index for columns
BUG: parser can handle a common_format multi-column index (no row index cols), (GH4702)
Thanks @jreback! |
closes #4702, should help with #5254
Will handle the format generated by
to_csv
(which has a an 'extra' line for the index names)and the more 'common' format
equiv to
no index col