-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
API: MultiIndex.labels -> codes #13443
Comments
IIRC this originally came from R land. I actually have no problem with this, esp for consistency. its a tiny bit tricky to do this because you have to accept both args for a while. |
I personally also find the current naming confusing (but indeed separate question is if there is something better that is workable to change to) Besides |
+1 for the attribute names |
Yes certainly (I didn't want to imply that). That is the logical use for this name, and that is what makes the 'other' levels a confusing name. BTW, I also think that the current repr is not the best one. As @shoyer put, the levels/labels are 'mostly internal', so then we shouldn't show them by default in repr? But will open a separate issue for that. EDIT -> #13480 |
|
anyone have appetite for changing I think this would be a positive change here. (let's leave |
@chris-b1 do you want to do this one? |
I would like to take this on, after #22511 is merged. So I'll do: |
@topper-123 Very welcome to take this up! I think your summary is correct. Only, I don't think it needs to depend on #22511, as it is (AFAIU) independent of the repr. |
Hey @jorisvandenbossche, I'm thinking about the repr output and doc strings here. If it weren't for #22511, the repr output would change from I had a working implementation of this a week ago (locally, was not pushed), so should be easy to update, but would prefer to get the repr issue settled before pushing. |
@topper-123 I think you could ignore the repr here (only change the internals and the method/attribute names, and leave the repr alone). Of course we need to change the repr eventually, but since you have the other PR, I would not worry about it here. |
Please see these links for the rational if interested: pandas-dev/pandas#13443 pandas-dev/pandas#23752
* Use MultiIndex.codes instead of labels (no longer support) Please see these links for the rational if interested: pandas-dev/pandas#13443 pandas-dev/pandas#23752 * Unpack and name values returned by _reindex_with_metadata This makes it easier to see what's going on below with the values returned by this function. * Initial patch to handle new pandas error This prevents attempting to drop columns that don't exist in merged.columns after setting the index, while still dropping columns that are present in merged.columns. Attempting to do so raises an exception in pandas >= 1. Please see pandas-dev/pandas#8594 for details. * Avoid mutating `merged` in place by assigning to new variable This avoids attempting to drop columns that had already been dropped in previous calls to _reindex_with_metadata in the for loop in `alpha_rarefaction`. Co-authored-by: Matthew Dillon <matthewrdillon@gmail.com> Co-authored-by: Matthew Dillon <matthewrdillon@gmail.com>
The boat may have long sailed on this, but just for consideration.
I semi-frequently get the
.levels
and.labels
of aMultiIndex
backwards. Maybe it's just me, but I thinklabels
is the culprit, because in other pandas contexts, "labels" refer to the actual value of the thing. E.g..loc
indexes by "labels" (values)So, consistent with
Categorical
, would it make sense for the integer mapping inside aMultiIndex
to also be called.codes
?The text was updated successfully, but these errors were encountered: