Skip to content

Commit ee2eb22

Browse files
committed
ENH: Groupby.plot enhancement
1 parent 5531341 commit ee2eb22

File tree

3 files changed

+411
-144
lines changed

3 files changed

+411
-144
lines changed

pandas/core/groupby.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -3279,9 +3279,13 @@ def _apply_to_column_groupbys(self, func):
32793279
in self._iterate_column_groupbys()),
32803280
keys=self._selected_obj.columns, axis=1)
32813281

3282-
from pandas.tools.plotting import boxplot_frame_groupby
3282+
3283+
from pandas.tools.plotting import boxplot_frame_groupby, plot_grouped
32833284
DataFrameGroupBy.boxplot = boxplot_frame_groupby
32843285

3286+
SeriesGroupBy.plot = plot_grouped
3287+
DataFrameGroupBy.plot = plot_grouped
3288+
32853289

32863290
class PanelGroupBy(NDFrameGroupBy):
32873291

pandas/tests/test_groupby.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4606,9 +4606,10 @@ def test_frame_groupby_plot_boxplot(self):
46064606
df = DataFrame({'height': height, 'weight': weight, 'gender': gender})
46074607
gb = df.groupby('gender')
46084608

4609-
res = gb.plot()
4610-
self.assertEqual(len(plt.get_fignums()), 2)
4611-
self.assertEqual(len(res), 2)
4609+
with assertRaisesRegexp(ValueError, "To plot DataFrameGroupBy, specify 'suplots=True'"):
4610+
res = gb.plot()
4611+
self.assertEqual(len(plt.get_fignums()), 2)
4612+
self.assertEqual(len(res), 2)
46124613
tm.close()
46134614

46144615
res = gb.boxplot()

0 commit comments

Comments
 (0)