Skip to content

Commit e70736b

Browse files
committed
revert to Appender in dynamically generated functions
1 parent ad9096f commit e70736b

File tree

1 file changed

+93
-97
lines changed

1 file changed

+93
-97
lines changed

pandas/core/generic.py

Lines changed: 93 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -10521,6 +10521,60 @@ def _doc_parms(cls):
1052110521
%(examples)s
1052210522
"""
1052310523

10524+
_num_ddof_doc = """
10525+
%(desc)s
10526+
Parameters
10527+
----------
10528+
axis : %(axis_descr)s
10529+
skipna : bool, default True
10530+
Exclude NA/null values. If an entire row/column is NA, the result
10531+
will be NA.
10532+
level : int or level name, default None
10533+
If the axis is a MultiIndex (hierarchical), count along a
10534+
particular level, collapsing into a %(name1)s.
10535+
ddof : int, default 1
10536+
Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
10537+
where N represents the number of elements.
10538+
numeric_only : bool, default None
10539+
Include only float, int, boolean columns. If None, will attempt to use
10540+
everything, then use only numeric data. Not implemented for Series.
10541+
Returns
10542+
-------
10543+
%(name1)s or %(name2)s (if level specified)\n"""
10544+
10545+
_bool_doc = """
10546+
%(desc)s
10547+
Parameters
10548+
----------
10549+
axis : {0 or 'index', 1 or 'columns', None}, default 0
10550+
Indicate which axis or axes should be reduced.
10551+
* 0 / 'index' : reduce the index, return a Series whose index is the
10552+
original column labels.
10553+
* 1 / 'columns' : reduce the columns, return a Series whose index is the
10554+
original index.
10555+
* None : reduce all axes, return a scalar.
10556+
bool_only : bool, default None
10557+
Include only boolean columns. If None, will attempt to use everything,
10558+
then use only boolean data. Not implemented for Series.
10559+
skipna : bool, default True
10560+
Exclude NA/null values. If the entire row/column is NA and skipna is
10561+
True, then the result will be %(empty_value)s, as for an empty row/column.
10562+
If skipna is False, then NA are treated as True, because these are not
10563+
equal to zero.
10564+
level : int or level name, default None
10565+
If the axis is a MultiIndex (hierarchical), count along a
10566+
particular level, collapsing into a %(name1)s.
10567+
**kwargs : any, default None
10568+
Additional keywords have no effect but might be accepted for
10569+
compatibility with NumPy.
10570+
Returns
10571+
-------
10572+
%(name1)s or %(name2)s
10573+
If level is specified, then, %(name2)s is returned; otherwise, %(name1)s
10574+
is returned.
10575+
%(see_also)s
10576+
%(examples)s"""
10577+
1052410578
_all_desc = """\
1052510579
Return whether all elements are True, potentially over an axis.
1052610580
@@ -10581,6 +10635,36 @@ def _doc_parms(cls):
1058110635
DataFrame.any : Return True if one (or more) elements are True.
1058210636
"""
1058310637

10638+
_cnum_doc = """
10639+
Return cumulative %(desc)s over a DataFrame or Series axis.
10640+
Returns a DataFrame or Series of the same size containing the cumulative
10641+
%(desc)s.
10642+
Parameters
10643+
----------
10644+
axis : {0 or 'index', 1 or 'columns'}, default 0
10645+
The index or the name of the axis. 0 is equivalent to None or 'index'.
10646+
skipna : bool, default True
10647+
Exclude NA/null values. If an entire row/column is NA, the result
10648+
will be NA.
10649+
*args, **kwargs
10650+
Additional keywords have no effect but might be accepted for
10651+
compatibility with NumPy.
10652+
Returns
10653+
-------
10654+
%(name1)s or %(name2)s
10655+
Return cumulative %(desc)s of %(name1)s or %(name2)s.
10656+
See Also
10657+
--------
10658+
core.window.Expanding.%(accum_func_name)s : Similar functionality
10659+
but ignores ``NaN`` values.
10660+
%(name2)s.%(accum_func_name)s : Return the %(desc)s over
10661+
%(name2)s axis.
10662+
%(name2)s.cummax : Return cumulative maximum over %(name2)s axis.
10663+
%(name2)s.cummin : Return cumulative minimum over %(name2)s axis.
10664+
%(name2)s.cumsum : Return cumulative sum over %(name2)s axis.
10665+
%(name2)s.cumprod : Return cumulative product over %(name2)s axis.
10666+
%(examples)s"""
10667+
1058410668
_cummin_examples = """\
1058510669
Examples
1058610670
--------
@@ -11149,32 +11233,11 @@ def stat_func(
1114911233
def _make_stat_function_ddof(
1115011234
cls, name: str, name1: str, name2: str, axis_descr: str, desc: str, func: Callable
1115111235
) -> Callable:
11152-
@doc(desc=desc, name1=name1, name2=name2, axis_descr=axis_descr)
11236+
@Substitution(desc=desc, name1=name1, name2=name2, axis_descr=axis_descr)
11237+
@Appender(_num_ddof_doc)
1115311238
def stat_func(
1115411239
self, axis=None, skipna=None, level=None, ddof=1, numeric_only=None, **kwargs
1115511240
):
11156-
"""
11157-
{desc}
11158-
11159-
Parameters
11160-
----------
11161-
axis : {axis_descr}
11162-
skipna : bool, default True
11163-
Exclude NA/null values. If an entire row/column is NA, the result
11164-
will be NA.
11165-
level : int or level name, default None
11166-
If the axis is a MultiIndex (hierarchical), count along a
11167-
particular level, collapsing into a %(name1)s.
11168-
ddof : int, default 1
11169-
Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
11170-
where N represents the number of elements.
11171-
numeric_only : bool, default None
11172-
Include only float, int, boolean columns. If None, will attempt to use
11173-
everything, then use only numeric data. Not implemented for Series.
11174-
11175-
Returns
11176-
-------
11177-
{name1} or {name2} (if level specified)\n"""
1117811241
nv.validate_stat_ddof_func(tuple(), kwargs, fname=name)
1117911242
if skipna is None:
1118011243
skipna = True
@@ -11202,48 +11265,16 @@ def _make_cum_function(
1120211265
accum_func_name: str,
1120311266
examples: str,
1120411267
) -> Callable:
11205-
@doc(
11268+
@Substitution(
1120611269
desc=desc,
1120711270
name1=name1,
1120811271
name2=name2,
11272+
axis_descr=axis_descr,
1120911273
accum_func_name=accum_func_name,
1121011274
examples=examples,
1121111275
)
11276+
@Appender(_cnum_doc)
1121211277
def cum_func(self, axis=None, skipna=True, *args, **kwargs):
11213-
"""
11214-
Return cumulative {desc} over a DataFrame or Series axis.
11215-
11216-
Returns a DataFrame or Series of the same size containing the cumulative
11217-
{desc}.
11218-
11219-
Parameters
11220-
----------
11221-
axis : {{0 or 'index', 1 or 'columns'}}, default 0
11222-
The index or the name of the axis. 0 is equivalent to None or 'index'.
11223-
skipna : bool, default True
11224-
Exclude NA/null values. If an entire row/column is NA, the result
11225-
will be NA.
11226-
*args, **kwargs
11227-
Additional keywords have no effect but might be accepted for
11228-
compatibility with NumPy.
11229-
11230-
Returns
11231-
-------
11232-
{name1} or {name2}
11233-
Return cumulative {desc} of {name1} or {name2}.
11234-
11235-
See Also
11236-
--------
11237-
core.window.Expanding.{accum_func_name} : Similar functionality
11238-
but ignores ``NaN`` values.
11239-
{name2}.{accum_func_name} : Return the {desc} over
11240-
{name2} axis.
11241-
{name2}.cummax : Return cumulative maximum over {name2} axis.
11242-
{name2}.cummin : Return cumulative minimum over {name2} axis.
11243-
{name2}.cumsum : Return cumulative sum over {name2} axis.
11244-
{name2}.cumprod : Return cumulative product over {name2} axis.
11245-
11246-
{examples}"""
1124711278
skipna = nv.validate_cum_func_with_skipna(skipna, args, kwargs, name)
1124811279
if axis is None:
1124911280
axis = self._stat_axis_number
@@ -11280,52 +11311,17 @@ def _make_logical_function(
1128011311
examples: str,
1128111312
empty_value: bool,
1128211313
) -> Callable:
11283-
@doc(
11314+
@Substitution(
1128411315
desc=desc,
1128511316
name1=name1,
1128611317
name2=name2,
11318+
axis_descr=axis_descr,
1128711319
see_also=see_also,
1128811320
examples=examples,
11289-
empty_value=str(empty_value),
11321+
empty_value=empty_value,
1129011322
)
11323+
@Appender(_bool_doc)
1129111324
def logical_func(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs):
11292-
"""
11293-
{desc}
11294-
11295-
Parameters
11296-
----------
11297-
axis : {{0 or 'index', 1 or 'columns', None}}, default 0
11298-
Indicate which axis or axes should be reduced.
11299-
11300-
* 0 / 'index' : reduce the index, return a Series whose index is the
11301-
original column labels.
11302-
* 1 / 'columns' : reduce the columns, return a Series whose index is the
11303-
original index.
11304-
* None : reduce all axes, return a scalar.
11305-
11306-
bool_only : bool, default None
11307-
Include only boolean columns. If None, will attempt to use everything,
11308-
then use only boolean data. Not implemented for Series.
11309-
skipna : bool, default True
11310-
Exclude NA/null values. If the entire row/column is NA and skipna is
11311-
True, then the result will be {empty_value}, as for an empty row/column.
11312-
If skipna is False, then NA are treated as True, because these are not
11313-
equal to zero.
11314-
level : int or level name, default None
11315-
If the axis is a MultiIndex (hierarchical), count along a
11316-
particular level, collapsing into a {name1}.
11317-
**kwargs : any, default None
11318-
Additional keywords have no effect but might be accepted for
11319-
compatibility with NumPy.
11320-
11321-
Returns
11322-
-------
11323-
{name1} or {name2}
11324-
If level is specified, then, {name2} is returned; otherwise, {name1}
11325-
is returned.
11326-
11327-
{see_also}
11328-
{examples}"""
1132911325
nv.validate_logical_func(tuple(), kwargs, fname=name)
1133011326
if level is not None:
1133111327
if bool_only is not None:

0 commit comments

Comments
 (0)