Skip to content

Commit 5778573

Browse files
TomAugspurgerjreback
authored andcommitted
DOC: Use shared docstring
1 parent a0692be commit 5778573

File tree

6 files changed

+19
-50
lines changed

6 files changed

+19
-50
lines changed

doc/source/groupby.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ the values in column 1 where the group is "B" are 3 higher on average.
925925
926926
We can easily visualize this with a boxplot:
927927

928-
..ipython:: python
928+
.. ipython:: python
929929
930930
@savefig groupby_boxplot.png
931931
bp = df.groupby('g').boxplot()
@@ -938,7 +938,8 @@ See the :ref:`visualization documentation<visualization.box>` for more.
938938
.. warning::
939939

940940
For historical reasons, ``df.groupby("g").boxplot()`` is not equivalent
941-
to ``df.boxplot(by="g")``. See :ref:`here<visualization.box.return>`.
941+
to ``df.boxplot(by="g")``. See :ref:`here<visualization.box.return>` for
942+
an explanation.
942943

943944
Examples
944945
--------

doc/source/release.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ Deprecations
262262
default output is unchanged.
263263

264264
- The default return type of :func:`boxplot` will change from a dict to a matpltolib Axes
265-
in a future release. You can use the future behavior now by passing ``return_type='dict'``
265+
in a future release. You can use the future behavior now by passing ``return_type='axes'``
266266
to boxplot.
267267

268268
Prior Version Deprecations/Changes

doc/source/v0.14.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ Deprecations
579579
default output is unchanged.
580580

581581
- The default return type of :func:`boxplot` will change from a dict to a matpltolib Axes
582-
in a future release. You can use the future behavior now by passing ``return_type='dict'``
582+
in a future release. You can use the future behavior now by passing ``return_type='axes'``
583583
to boxplot.
584584

585585
.. _whatsnew_0140.enhancements:

doc/source/visualization.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,15 @@ DataFrame.
331331
df_box['g'] = np.random.choice(['A', 'B'], size=50)
332332
df_box.loc[df_box['g'] == 'B', 1] += 3
333333
334-
..ipython:: python
334+
@savefig boxplot_groupby.png
335+
bp = df_box.boxplot(by='g')
335336
336-
@savefig(boxplot_groupby.png)
337-
df_box.boxplot(by='g')
337+
Compare to:
338338

339-
@savefig groupby_boxplot_vis.png
340-
df_box.groupby('g').boxplot()
339+
.. ipython:: python
341340
341+
@savefig groupby_boxplot_vis.png
342+
bp = df_box.groupby('g').boxplot()
342343
343344
.. _visualization.area_plot:
344345

pandas/core/frame.py

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4856,48 +4856,15 @@ def _put_str(s, space):
48564856
DataFrame.hist = gfx.hist_frame
48574857

48584858

4859+
@Appender(_shared_docs['boxplot'] % _shared_doc_kwargs)
48594860
def boxplot(self, column=None, by=None, ax=None, fontsize=None,
48604861
rot=0, grid=True, figsize=None, layout=None, return_type=None,
48614862
**kwds):
4862-
"""
4863-
Make a box plot from DataFrame column/columns optionally grouped
4864-
(stratified) by one or more columns
4865-
4866-
Parameters
4867-
----------
4868-
data : DataFrame
4869-
column : column names or list of names, or vector
4870-
Can be any valid input to groupby
4871-
by : string or sequence
4872-
Column in the DataFrame to group by
4873-
ax : matplotlib axis object, default None
4874-
fontsize : int or string
4875-
rot : int, default None
4876-
Rotation for ticks
4877-
grid : boolean, default None (matlab style default)
4878-
Axis grid lines
4879-
layout : tuple (optional)
4880-
(rows, columns) for the layout of the plot
4881-
return_type : bool, default False
4882-
Whether to return a dict whose values are the lines of the boxplot
4883-
kwds : other plotting keyword arguments to be passed to matplotlib boxplot
4884-
function
4885-
4886-
Returns
4887-
-------
4888-
ax : matplotlib.axes.AxesSubplot
4889-
lines : dict (optional)
4890-
4891-
Notes
4892-
-----
4893-
Use ``return_dict=True`` when you want to modify the appearance
4894-
of the lines. In this case a named tuple is returned.
4895-
"""
48964863
import pandas.tools.plotting as plots
48974864
import matplotlib.pyplot as plt
48984865
ax = plots.boxplot(self, column=column, by=by, ax=ax,
48994866
fontsize=fontsize, grid=grid, rot=rot,
4900-
figsize=figsize, layout=layout, return_dict=return_dict,
4867+
figsize=figsize, layout=layout, return_type=return_type,
49014868
**kwds)
49024869
plt.draw_if_interactive()
49034870
return ax

pandas/tools/plotting.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from pandas.util.decorators import cache_readonly, deprecate_kwarg
1313
import pandas.core.common as com
14+
from pandas.core.generic import _shared_docs, _shared_doc_kwargs
1415
from pandas.core.index import MultiIndex
1516
from pandas.core.series import Series, remove_na
1617
from pandas.tseries.index import DatetimeIndex
@@ -19,6 +20,7 @@
1920
from pandas.tseries.offsets import DateOffset
2021
from pandas.compat import range, lrange, lmap, map, zip, string_types
2122
import pandas.compat as compat
23+
from pandas.util.decorators import Appender
2224

2325
try: # mpl optional
2426
import pandas.tseries.converter as conv
@@ -2258,16 +2260,13 @@ def plot_series(series, label=None, kind='line', use_index=True, rot=None,
22582260
return plot_obj.axes[0]
22592261

22602262

2261-
def boxplot(data, column=None, by=None, ax=None, fontsize=None,
2262-
rot=0, grid=True, figsize=None, layout=None, return_type=None,
2263-
**kwds):
2264-
"""
2263+
_shared_docs['boxplot'] = """
22652264
Make a box plot from DataFrame column optionally grouped by some columns or
22662265
other inputs
22672266
22682267
Parameters
22692268
----------
2270-
data : DataFrame or Series
2269+
data : the pandas object holding the data
22712270
column : column name or list of names, or vector
22722271
Can be any valid input to groupby
22732272
by : string or sequence
@@ -2299,7 +2298,7 @@ def boxplot(data, column=None, by=None, ax=None, fontsize=None,
22992298
23002299
Notes
23012300
-----
2302-
Use ``return_dict=True`` when you want to tweak the appearance
2301+
Use ``return_type='dict'`` when you want to tweak the appearance
23032302
of the lines after plotting. In this case a dict containing the Lines
23042303
making up the boxes, caps, fliers, medians, and whiskers is returned.
23052304
"""
@@ -2315,6 +2314,7 @@ def boxplot(data, column=None, by=None, ax=None, fontsize=None,
23152314
if return_type not in valid_types:
23162315
raise ValueError("return_type")
23172316

2317+
23182318
from pandas import Series, DataFrame
23192319
if isinstance(data, Series):
23202320
data = DataFrame({'x': data})

0 commit comments

Comments
 (0)