-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH/API: Allow dicts with tuple keys in DataFrame constructor #3323
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
This looks like a natural extension to me, marked for consideration in 0.12. |
I haven't fully tested it yet, but it looks like changing the call to |
Whoops that's not entirely precise: it should be a call to one of the class method helpers. |
Just need to consider the case where users want tuple labels for some reason.
|
I'm not sure how to address that case without something annoying like a flag in the constructor. I guess my point in raising the issue was for cases like that. It seems like an |
One difference is that the |
it's a question of backcompat mostly, tupes are valid labels right now, There's nothing inherent in tuples that makes them mean levels. it's |
To implement this behavior for both the |
This would also solve the issue that when you call |
Is this worth keeping open? I'll hack on it if it is, but as @y-p said there's no reason tuples must be multilevel indices, they just happen to be implemented that way. I'm just not sure if this is too big of a breaking change. |
making this possible would be go, but the constructor is overloaded to |
Same for multiindex to DataFrame (not working atm)
As @cpcloud mentions it's m.values doesn't work "as expected" (especially shape):
Possibly related #4187 |
i think the numpy attribute consistency can be added in a separate PR |
pushing to 0.14 |
closed via #4805 |
related #4805
It would be nice to allow automatic conversion to a MultiIndex when a
dict
with tuple keys is passed into theDataFrame
constructor. Here's what currently happens:The same issue shows up in
pd.concat
when you pass in adict
of sequences (lists and ndarrays and friends) andaxis=1
, however if you have adict
ofDataFrames
the columns keys are converted to a MultiIndex. E.g.,The text was updated successfully, but these errors were encountered: