From 3f240fc36106027cda783c5429fa697409f2d5bd Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Sun, 2 Feb 2025 16:53:22 +0700 Subject: [PATCH 1/5] Add test --- pandas/tests/io/formats/test_printing.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandas/tests/io/formats/test_printing.py b/pandas/tests/io/formats/test_printing.py index 3b63011bf862e..f86b4af2647f8 100644 --- a/pandas/tests/io/formats/test_printing.py +++ b/pandas/tests/io/formats/test_printing.py @@ -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)" + class TestFormatBase: def test_adjoin(self): From ca3751e81d2f1c5b9735c9d1dd0b31645c10e8ed Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Sun, 2 Feb 2025 16:53:49 +0700 Subject: [PATCH 2/5] handle frozenset --- pandas/io/formats/printing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/io/formats/printing.py b/pandas/io/formats/printing.py index a9936ba8c8f2c..a730ac24e6c87 100644 --- a/pandas/io/formats/printing.py +++ b/pandas/io/formats/printing.py @@ -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})" From 65a942084a8cf76c59c200770bbb8e1574f79239 Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Tue, 4 Feb 2025 08:37:45 +0700 Subject: [PATCH 3/5] add whatsnew --- doc/source/whatsnew/v3.0.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index 64f4a66a109f5..59ca4338cf222 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -74,6 +74,7 @@ Other enhancements - Support passing a :class:`Iterable[Hashable]` input to :meth:`DataFrame.drop_duplicates` (:issue:`59237`) - Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`) - Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`) +- ``frozenset`` are now pretty printted (:issue:`60690`) .. --------------------------------------------------------------------------- .. _whatsnew_300.notable_bug_fixes: From 168cbe434a2a7cacda9b1315b479017dfd701602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quang=20Nguy=E1=BB=85n?= <30631476+quangngd@users.noreply.github.com> Date: Wed, 5 Feb 2025 07:01:53 +0700 Subject: [PATCH 4/5] Update doc/source/whatsnew/v3.0.0.rst Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- doc/source/whatsnew/v3.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index 59ca4338cf222..8e9c58e769b82 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -74,7 +74,7 @@ Other enhancements - Support passing a :class:`Iterable[Hashable]` input to :meth:`DataFrame.drop_duplicates` (:issue:`59237`) - Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`) - Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`) -- ``frozenset`` are now pretty printted (:issue:`60690`) +- :py:class:`frozenset` elements in pandas objects are now natively printed (:issue:`60690`) .. --------------------------------------------------------------------------- .. _whatsnew_300.notable_bug_fixes: From a5413128ff804e8e500ef2f4d16f07d3abffbe1c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2025 00:09:34 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/source/whatsnew/v3.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index 8e9c58e769b82..08a38270a6fb0 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -68,13 +68,13 @@ Other enhancements - :meth:`Series.map` can now accept kwargs to pass on to func (:issue:`59814`) - :meth:`Series.str.get_dummies` now accepts a ``dtype`` parameter to specify the dtype of the resulting DataFrame (:issue:`47872`) - :meth:`pandas.concat` will raise a ``ValueError`` when ``ignore_index=True`` and ``keys`` is not ``None`` (:issue:`59274`) +- :py:class:`frozenset` elements in pandas objects are now natively printed (:issue:`60690`) - Implemented :meth:`Series.str.isascii` and :meth:`Series.str.isascii` (:issue:`59091`) - Multiplying two :class:`DateOffset` objects will now raise a ``TypeError`` instead of a ``RecursionError`` (:issue:`59442`) - Restore support for reading Stata 104-format and enable reading 103-format dta files (:issue:`58554`) - Support passing a :class:`Iterable[Hashable]` input to :meth:`DataFrame.drop_duplicates` (:issue:`59237`) - Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`) - Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`) -- :py:class:`frozenset` elements in pandas objects are now natively printed (:issue:`60690`) .. --------------------------------------------------------------------------- .. _whatsnew_300.notable_bug_fixes: