From cabd4408878a9d6e622c064e12be790979406c5f Mon Sep 17 00:00:00 2001 From: iansheng Date: Sun, 20 Mar 2022 23:27:36 +0800 Subject: [PATCH 1/4] Plot according to a series with empty column name. --- pandas/plotting/_matplotlib/core.py | 2 +- pandas/tests/plotting/frame/test_frame.py | 2 +- pandas/tests/plotting/test_series.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py index 48875114794d9..7559b042ea7e7 100644 --- a/pandas/plotting/_matplotlib/core.py +++ b/pandas/plotting/_matplotlib/core.py @@ -458,7 +458,7 @@ def _compute_plot_data(self): if isinstance(data, ABCSeries): label = self.label if label is None and data.name is None: - label = "None" + label = "" if label is None: # We'll end up with columns of [0] instead of [None] data = data.to_frame() diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 62540a15f47bd..2fab7d0fdbc74 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -1189,7 +1189,7 @@ def test_line_label_none(self): assert ax.get_legend() is None ax = s.plot(legend=True) - assert ax.get_legend().get_texts()[0].get_text() == "None" + assert ax.get_legend().get_texts()[0].get_text() == "" @pytest.mark.parametrize( "props, expected", diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index d0ed5cb754c40..c49354816b8b0 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -179,7 +179,7 @@ def test_label(self): self.plt.close() _, ax = self.plt.subplots() ax = s.plot(legend=True, ax=ax) - self._check_legend_labels(ax, labels=["None"]) + self._check_legend_labels(ax, labels=[""]) self.plt.close() # get name from index s.name = "NAME" From f84f8590e8cd62d41a9f2cc936fe213904a0b7e8 Mon Sep 17 00:00:00 2001 From: iansheng Date: Sun, 20 Mar 2022 23:40:05 +0800 Subject: [PATCH 2/4] Fix showing "None" as ylabel in :meth:`Series.plot` when not setting ylabel --- doc/source/whatsnew/v1.4.2.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.2.rst b/doc/source/whatsnew/v1.4.2.rst index 06f1f406c3816..0ae32e3419d80 100644 --- a/doc/source/whatsnew/v1.4.2.rst +++ b/doc/source/whatsnew/v1.4.2.rst @@ -30,7 +30,7 @@ Bug fixes ~~~~~~~~~ - Fix some cases for subclasses that define their ``_constructor`` properties as general callables (:issue:`46018`) - Fixed "longtable" formatting in :meth:`.Styler.to_latex` when ``column_format`` is given in extended format (:issue:`46037`) -- +- Fix showing "None" as ylabel in :meth:`Series.plot` when not setting ylabel (:issue:`46129`) .. --------------------------------------------------------------------------- From f4d2f1991aa9e7efce2e8fdef1223a603af9f4b2 Mon Sep 17 00:00:00 2001 From: iansheng Date: Mon, 21 Mar 2022 22:25:39 +0800 Subject: [PATCH 3/4] Fix showing "None" as ylabel in :meth:`Series.plot` when not setting ylabel --- doc/source/whatsnew/v1.4.2.rst | 2 +- doc/source/whatsnew/v1.5.0.rst | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.2.rst b/doc/source/whatsnew/v1.4.2.rst index 0ae32e3419d80..06f1f406c3816 100644 --- a/doc/source/whatsnew/v1.4.2.rst +++ b/doc/source/whatsnew/v1.4.2.rst @@ -30,7 +30,7 @@ Bug fixes ~~~~~~~~~ - Fix some cases for subclasses that define their ``_constructor`` properties as general callables (:issue:`46018`) - Fixed "longtable" formatting in :meth:`.Styler.to_latex` when ``column_format`` is given in extended format (:issue:`46037`) -- Fix showing "None" as ylabel in :meth:`Series.plot` when not setting ylabel (:issue:`46129`) +- .. --------------------------------------------------------------------------- diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 8dac952874f89..2712070efe75f 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -109,6 +109,13 @@ did not have the same index as the input. df.groupby('a', dropna=True).transform(lambda x: x) df.groupby('a', dropna=True).transform('sum') +.. _whatsnew_150.notable_bug_fixes.visualization + +Styler +^^^^^^ + +- Fix showing "None" as ylabel in :meth:`Series.plot` when not setting ylabel (:issue:`46129`) + .. _whatsnew_150.notable_bug_fixes.notable_bug_fix2: notable_bug_fix2 From 814b59a6c83238b7c77f25741768cf7fc415bfc6 Mon Sep 17 00:00:00 2001 From: iansheng Date: Mon, 21 Mar 2022 23:16:44 +0800 Subject: [PATCH 4/4] bug fix in doc/source/whatsnew/v1.5.0.rst --- doc/source/whatsnew/v1.5.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 2712070efe75f..1fdfd99d3ff53 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -109,7 +109,7 @@ did not have the same index as the input. df.groupby('a', dropna=True).transform(lambda x: x) df.groupby('a', dropna=True).transform('sum') -.. _whatsnew_150.notable_bug_fixes.visualization +.. _whatsnew_150.notable_bug_fixes.visualization: Styler ^^^^^^