You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #23752, the MultiIndex signature was changed. Compared to 0.23.4, the only change is that labels has been changed to codes.
Now that the signature is being changed anyway, I've started to think about if this is even the right signature:
I think codes should actually be an implementation detail, and an improved signature would be using data for the first parameter, similarly to how data is the first parameter in the signature for CategoricalIndex. So a signauture like this:
In the first example, I use the current initalisation method, and in the second I show a initalisation with a dict, similar to how a DataFrame is initalized with a dict.
I think this could make the initialisation of MultiIndex more similar to the ones for the other pandas objects, and make MultiIndexes more friendly to use for users.
The text was updated successfully, but these errors were encountered:
and make MultiIndexes more friendly to use for users.
We already provide the alternative constructors. What's wrong with using those?
I'd caution against putting too much magic in the MultiIndex constructor. That kind of thing has made the Series and DataFrame constructors difficult to maintain.
we already have 3 different ways of constructing MultiIndex, which is enough; they are different enough that it would be very awkward to do this in a single constructor. The main constructor () should rarely be used directly.
In #23752, the MultiIndex signature was changed. Compared to 0.23.4, the only change is that
labels
has been changed tocodes
.Now that the signature is being changed anyway, I've started to think about if this is even the right signature:
I think
codes
should actually be an implementation detail, and an improved signature would be usingdata
for the first parameter, similarly to howdata
is the first parameter in the signature forCategoricalIndex
. So a signauture like this:I think would be better.
data
could then accept codes, but could also accept other types of data, that could be used to construct aMultiIndex
. For example:In the first example, I use the current initalisation method, and in the second I show a initalisation with a dict, similar to how a DataFrame is initalized with a dict.
I think this could make the initialisation of MultiIndex more similar to the ones for the other pandas objects, and make MultiIndexes more friendly to use for users.
The text was updated successfully, but these errors were encountered: