diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 9a79ca1d4eab1..0cd1c0e05ce21 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -5651,12 +5651,21 @@ def isin(self, values): values).reshape(self.shape), self.index, self.columns) + # ---------------------------------------------------------------------- + # Add plotting methods to DataFrame + plot = base.AccessorProperty(gfx.FramePlotMethods, gfx.FramePlotMethods) + hist = gfx.hist_frame + boxplot = gfx.boxplot_frame + DataFrame._setup_axes(['index', 'columns'], info_axis=1, stat_axis=0, axes_are_reversed=True, aliases={'rows': 0}) DataFrame._add_numeric_operations() DataFrame._add_series_or_dataframe_operations() +ops.add_flex_arithmetic_methods(DataFrame, **ops.frame_flex_funcs) +ops.add_special_arithmetic_methods(DataFrame, **ops.frame_special_funcs) + _EMPTY_SERIES = Series([]) @@ -6002,28 +6011,3 @@ def _from_nested_dict(data): def _put_str(s, space): return ('%s' % s)[:space].ljust(space) - - -# ---------------------------------------------------------------------- -# Add plotting methods to DataFrame -DataFrame.plot = base.AccessorProperty(gfx.FramePlotMethods, - gfx.FramePlotMethods) -DataFrame.hist = gfx.hist_frame - - -@Appender(_shared_docs['boxplot'] % _shared_doc_kwargs) -def boxplot(self, column=None, by=None, ax=None, fontsize=None, rot=0, - grid=True, figsize=None, layout=None, return_type=None, **kwds): - from pandas.plotting._core import boxplot - import matplotlib.pyplot as plt - ax = boxplot(self, column=column, by=by, ax=ax, fontsize=fontsize, - grid=grid, rot=rot, figsize=figsize, layout=layout, - return_type=return_type, **kwds) - plt.draw_if_interactive() - return ax - - -DataFrame.boxplot = boxplot - -ops.add_flex_arithmetic_methods(DataFrame, **ops.frame_flex_funcs) -ops.add_special_arithmetic_methods(DataFrame, **ops.frame_special_funcs) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index a623288efc1ae..de96d17da2a9f 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -2034,6 +2034,18 @@ def plot_group(keys, values, ax): return result +@Appender(_shared_docs['boxplot'] % _shared_doc_kwargs) +def boxplot_frame(self, column=None, by=None, ax=None, fontsize=None, rot=0, + grid=True, figsize=None, layout=None, + return_type=None, **kwds): + import matplotlib.pyplot as plt + ax = boxplot(self, column=column, by=by, ax=ax, fontsize=fontsize, + grid=grid, rot=rot, figsize=figsize, layout=layout, + return_type=return_type, **kwds) + plt.draw_if_interactive() + return ax + + def scatter_plot(data, x, y, by=None, ax=None, figsize=None, grid=False, **kwargs): """