Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pandas/io/formats/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def _pprint_seq(
"""
if isinstance(seq, set):
fmt = "{{{body}}}"
elif isinstance(seq, frozenset):
fmt = "frozenset({body})"
else:
fmt = "[{body}]" if hasattr(seq, "__setitem__") else "({body})"

Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/io/formats/test_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def test_repr_dict(self):
def test_repr_mapping(self):
assert printing.pprint_thing(MyMapping()) == "{'a': 4, 'b': 4}"

def test_repr_frozenset(self):
assert printing.pprint_thing(frozenset([1, 2])) == "frozenset(1, 2)"
Copy link
Contributor

@wjandrea wjandrea Feb 6, 2025

Choose a reason for hiding this comment

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

The output should have braces: frozenset({1, 2})

Copy link
Contributor

Choose a reason for hiding this comment

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

I opened #60867



class TestFormatBase:
def test_adjoin(self):
Expand Down
Loading