-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Allow MultiIndex to be subclassed #11267 #11268
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
BUG: Allow MultiIndex to be subclassed #11267 #11268
Conversation
MultiIndex had several places where the output class was hard-coded to MultiIndex rather than cls, self.__class__, or the like. These have been replaced.
|
Should this use |
@MaximilianR yes |
I added a simple test of MultiIndex subclassing. As for I have another branch with |
I don't understand the comment about |
If you actually were to sub-class Simply sub-class testing is not nearly enough. You have to use the sub-classed index in operations and assert that they are propogated properly. |
@janmedlock I'm not the authority here, but to try and answer your Q on Although I'm not sure why pandas uses that standard rather than the direct reference to the class. |
@jreback The biggest issue was I changed all the |
@MaximilianR Yes, I understood that, but |
@janmedlock Ah, good point. |
class MyMultiIndex(MultiIndex): | ||
pass | ||
mi = MyMultiIndex([['a'], ['b']], [[0], [0]]) | ||
self.assertTrue(isinstance(mi, MyMultiIndex)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a fair bit of testing, e.g. run thru the some typical operations of a MI, just with a sub-class one.
closing, but if you'd like to update, pls reopen |
closes #11267
MultiIndex had several places where the output class was hard-coded to
MultiIndex rather than cls, self.class, or the like. These have
been replaced.