Skip to content

BUG: pretty print all Mappings, not just dicts #57915

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 1 commit into from
Mar 20, 2024

Conversation

NickCrews
Copy link
Contributor

@NickCrews NickCrews commented Mar 19, 2024

This was discovered in ibis-project/ibis#8687

Due to a strict isinstance(x, dict) check, custom mapping types would instead get treated as mere iterables, so only the keys would get printed as a tuple:

import pandas as pd
from ibis.common.collections import frozendict
pd.Series([frozendict({"a": 5, "b": 6})])
# 0    (a, b)
# dtype: object

@mroeschke mroeschke added the Output-Formatting __repr__ of pandas objects, to_string label Mar 19, 2024
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.

I think this would be OK. Could you come up with a test?

@NickCrews
Copy link
Contributor Author

that was a pretty nice experience setting up a dev environment locally, pass along my compliments to the rest of the pandas maintainers @mroeschke !

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 whatsnew note in v3.0.0.rst?

@mroeschke mroeschke added this to the 3.0 milestone Mar 19, 2024
@mroeschke mroeschke merged commit 924f246 into pandas-dev:main Mar 20, 2024
@mroeschke
Copy link
Member

Thanks @NickCrews

pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants