-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH?: __repr__ method for Index objects #5120
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
I think you need to fix the Index representation of itself instead, because levels and labels are just Index objects that are getting pprinted in an extremely long way, here's the relevant code to intercept: def __repr__(self):
encoding = get_option('display.encoding')
attrs = [('levels', default_pprint(self.levels)),
('labels', default_pprint(self.labels))]
if not all(name is None for name in self.names):
attrs.append(('names', default_pprint(self.names)))
if self.sortorder is not None:
attrs.append(('sortorder', default_pprint(self.sortorder))) If you want to put something together that shortens extremely long indexes, you just need to alter |
Thanks @jtratner I spotted this in index.py --- actually my idea was to modify this one. Thanks for the |
I think the correct config option is |
fwiw you'll also be able adjust the "edge" items once i push that PR |
I think it's reasonable. It just needs to be changed to what it actually is |
If we're not in a hurry I'm happy to look into this. Won't be before the weekend though, no time .... |
Push the milestone to 0.14. If you finish earlier we can incorporate it. |
Also see #5734 I think |
@y-p gr8 thanks! |
It often happens that I print a MultiIndex object (whether on purpose or not) which leads to flooding my interpreter and makes it unresponsive for a couple of seconds since often the length of my indexers exceeds 500-1000k. I was thinking about adding a neat
__repr__
for Indexers that summarizes levels + length or just omits what's in the middle once a certain length is exceeded. It seems this has not been tackled so far when looking at the current master, but please feel free to close this issue if this is a dupe (checked but did not find anything related). Any pointers are welcome.The text was updated successfully, but these errors were encountered: