Skip to content

BUG: MultiIndex displays incorrectly with a long element #53044

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

Merged
merged 5 commits into from
May 5, 2023

Conversation

Charlie-XIAO
Copy link
Contributor

if len(pprinted_seq) < max_space:
head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]
break

The if branch as shown above may never be visited, so head and tail may not be correctly set. This pull request fixes this problem.

@Charlie-XIAO Charlie-XIAO changed the title if branch may not be visited, so head and tail may not be correctly set BUG: format_object_summary not setting head and tail correctly May 2, 2023
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a unit test

@Charlie-XIAO
Copy link
Contributor Author

Sure, thanks for your review! I'll make the changes ASAP.

@Charlie-XIAO Charlie-XIAO changed the title BUG: format_object_summary not setting head and tail correctly BUG: MultiIndex displays incorrectly with a long element May 4, 2023
@Charlie-XIAO
Copy link
Contributor Author

@mroeschke Hi, I've made the unit test. However, I'm not sure if this is the correct way to do, so would you mind giving some instructions if I'm not doing correctly? Thank you very much.

@mroeschke mroeschke added Output-Formatting __repr__ of pandas objects, to_string MultiIndex labels May 5, 2023
@mroeschke mroeschke added this to the 2.1 milestone May 5, 2023
@mroeschke mroeschke merged commit 284cfb2 into pandas-dev:main May 5, 2023
@mroeschke
Copy link
Member

Thanks @Charlie-XIAO

topper-123 pushed a commit to topper-123/pandas that referenced this pull request May 7, 2023
…v#53044)

* if branch may not be visited, so head and tail may not be correctly set

* fixed pylint possibly undefined variable

* updated changelog

* added unit test
Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
…v#53044)

* if branch may not be visited, so head and tail may not be correctly set

* fixed pylint possibly undefined variable

* updated changelog

* added unit test
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
…v#53044)

* if branch may not be visited, so head and tail may not be correctly set

* fixed pylint possibly undefined variable

* updated changelog

* added unit test
@Charlie-XIAO Charlie-XIAO deleted the fix-pprint-obj branch September 23, 2023 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiIndex Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: AttributeError: 'tuple' object has no attribute 'rstrip' in format_object_summary
2 participants