From f81fb8129f957e529b5777dbe9d0a021c936dadc Mon Sep 17 00:00:00 2001 From: Guillem Sanchez Date: Sat, 23 May 2020 17:56:25 +0200 Subject: [PATCH 1/5] Added missing import in boxplot_frame_groupby example --- doc/source/whatsnew/v1.1.0.rst | 1 + pandas/plotting/_core.py | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index bfe2dcee40d5e..3ed46f969fe53 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -804,6 +804,7 @@ Plotting - :func:`.plot` for line/bar now accepts color by dictonary (:issue:`8193`). - Bug in :meth:`DataFrame.plot.hist` where weights are not working for multiple columns (:issue:`33173`) - Bug in :meth:`DataFrame.boxplot` and :meth:`DataFrame.plot.boxplot` lost color attributes of ``medianprops``, ``whiskerprops``, ``capprops`` and ``medianprops`` (:issue:`30346`) +- Bug in :meth:`DataFrame.boxplot` where there is a missing import in a code example (:issue:`28903`) - Bug in :meth:`DataFrame.hist` where the order of ``column`` argument was ignored (:issue:`29235`) - Bug in :meth:`DataFrame.plot.scatter` that when adding multiple plots with different ``cmap``, colorbars alway use the first ``cmap`` (:issue:`33389`) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 32cd89383dde9..b95d7921d13e5 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -548,6 +548,7 @@ def boxplot_frame_groupby( Examples -------- >>> import itertools + >>> from pandas.plotting import boxplot_frame_groupby >>> tuples = [t for t in itertools.product(range(1000), range(4))] >>> index = pd.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1']) >>> data = np.random.randn(len(index),4) From cda5819a2167c6aeeec96498f6f4ed0f9b7258c7 Mon Sep 17 00:00:00 2001 From: Guillem Sanchez Date: Sat, 23 May 2020 20:11:45 +0200 Subject: [PATCH 2/5] Added plot in boxplot_frame_groupby example --- pandas/plotting/_core.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index b95d7921d13e5..0f09f09b8c8a7 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -547,18 +547,25 @@ def boxplot_frame_groupby( Examples -------- - >>> import itertools - >>> from pandas.plotting import boxplot_frame_groupby - >>> tuples = [t for t in itertools.product(range(1000), range(4))] - >>> index = pd.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1']) - >>> data = np.random.randn(len(index),4) - >>> df = pd.DataFrame(data, columns=list('ABCD'), index=index) - >>> - >>> grouped = df.groupby(level='lvl1') - >>> boxplot_frame_groupby(grouped) - >>> - >>> grouped = df.unstack(level='lvl1').groupby(level=0, axis=1) - >>> boxplot_frame_groupby(grouped, subplots=False) + You can create boxplots for grouped data and show them as separate subplots: + + .. plot:: + :context: close-figs + + >>> import itertools + >>> from pandas.plotting import boxplot_frame_groupby + >>> tuples = [t for t in itertools.product(range(1000), range(4))] + >>> index = pd.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1']) + >>> data = np.random.randn(len(index),4) + >>> df = pd.DataFrame(data, columns=list('ABCD'), index=index) + >>> grouped = df.groupby(level='lvl1') + >>> boxplot_frame_groupby(grouped, rot=45, fontsize=12) + The ``subplots=False`` option shows the boxplots in a single figure. + + .. plot:: + :context: close-figs + + >>> boxplot_frame_groupby(grouped, subplots=False, rot=45, fontsize=12) """ plot_backend = _get_plot_backend(backend) return plot_backend.boxplot_frame_groupby( From d0b1e16fb79e08002bb3fbe7badb358b5f0c73b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillem=20S=C3=A1nchez?= Date: Sun, 24 May 2020 11:45:45 +0000 Subject: [PATCH 3/5] Update pandas/plotting/_core.py Co-authored-by: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> --- doc/source/whatsnew/v1.1.0.rst | 1 - pandas/plotting/_core.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index 3ed46f969fe53..bfe2dcee40d5e 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -804,7 +804,6 @@ Plotting - :func:`.plot` for line/bar now accepts color by dictonary (:issue:`8193`). - Bug in :meth:`DataFrame.plot.hist` where weights are not working for multiple columns (:issue:`33173`) - Bug in :meth:`DataFrame.boxplot` and :meth:`DataFrame.plot.boxplot` lost color attributes of ``medianprops``, ``whiskerprops``, ``capprops`` and ``medianprops`` (:issue:`30346`) -- Bug in :meth:`DataFrame.boxplot` where there is a missing import in a code example (:issue:`28903`) - Bug in :meth:`DataFrame.hist` where the order of ``column`` argument was ignored (:issue:`29235`) - Bug in :meth:`DataFrame.plot.scatter` that when adding multiple plots with different ``cmap``, colorbars alway use the first ``cmap`` (:issue:`33389`) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 0f09f09b8c8a7..42a22e9280f0d 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -560,7 +560,8 @@ def boxplot_frame_groupby( >>> df = pd.DataFrame(data, columns=list('ABCD'), index=index) >>> grouped = df.groupby(level='lvl1') >>> boxplot_frame_groupby(grouped, rot=45, fontsize=12) - The ``subplots=False`` option shows the boxplots in a single figure. + + The ``subplots=False`` option shows the boxplots in a single figure. .. plot:: :context: close-figs From d952e850e1e1bd4967f52f9e8981b2cc194277ad Mon Sep 17 00:00:00 2001 From: Guillem Sanchez Date: Sat, 30 May 2020 13:06:47 +0200 Subject: [PATCH 4/5] Beautified plots, changed boxplot_frame_groupby by groupby.boxplot method --- pandas/plotting/_core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 42a22e9280f0d..7f324e63517c5 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -559,14 +559,14 @@ def boxplot_frame_groupby( >>> data = np.random.randn(len(index),4) >>> df = pd.DataFrame(data, columns=list('ABCD'), index=index) >>> grouped = df.groupby(level='lvl1') - >>> boxplot_frame_groupby(grouped, rot=45, fontsize=12) + >>> grouped.boxplot(rot=45, fontsize=12, figsize=(8,10)) The ``subplots=False`` option shows the boxplots in a single figure. .. plot:: :context: close-figs - >>> boxplot_frame_groupby(grouped, subplots=False, rot=45, fontsize=12) + >>> grouped.boxplot(subplots=False, rot=45, fontsize=12) """ plot_backend = _get_plot_backend(backend) return plot_backend.boxplot_frame_groupby( From dd0a1fe3a48f6be4052fffea2be3af73370e06d8 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 6 Jul 2020 09:53:33 -0500 Subject: [PATCH 5/5] Update pandas/plotting/_core.py --- pandas/plotting/_core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 7f324e63517c5..ad2b664b4c99b 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -553,7 +553,6 @@ def boxplot_frame_groupby( :context: close-figs >>> import itertools - >>> from pandas.plotting import boxplot_frame_groupby >>> tuples = [t for t in itertools.product(range(1000), range(4))] >>> index = pd.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1']) >>> data = np.random.randn(len(index),4)