Skip to content

Commit 926c901

Browse files
committed
revert to Appender in dynamically generated functions
1 parent 1248ad1 commit 926c901

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
@@ -10623,6 +10623,60 @@ def _doc_parms(cls):
1062310623
%(examples)s
1062410624
"""
1062510625

10626+
_num_ddof_doc = """
10627+
%(desc)s
10628+
Parameters
10629+
----------
10630+
axis : %(axis_descr)s
10631+
skipna : bool, default True
10632+
Exclude NA/null values. If an entire row/column is NA, the result
10633+
will be NA.
10634+
level : int or level name, default None
10635+
If the axis is a MultiIndex (hierarchical), count along a
10636+
particular level, collapsing into a %(name1)s.
10637+
ddof : int, default 1
10638+
Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
10639+
where N represents the number of elements.
10640+
numeric_only : bool, default None
10641+
Include only float, int, boolean columns. If None, will attempt to use
10642+
everything, then use only numeric data. Not implemented for Series.
10643+
Returns
10644+
-------
10645+
%(name1)s or %(name2)s (if level specified)\n"""
10646+
10647+
_bool_doc = """
10648+
%(desc)s
10649+
Parameters
10650+
----------
10651+
axis : {0 or 'index', 1 or 'columns', None}, default 0
10652+
Indicate which axis or axes should be reduced.
10653+
* 0 / 'index' : reduce the index, return a Series whose index is the
10654+
original column labels.
10655+
* 1 / 'columns' : reduce the columns, return a Series whose index is the
10656+
original index.
10657+
* None : reduce all axes, return a scalar.
10658+
bool_only : bool, default None
10659+
Include only boolean columns. If None, will attempt to use everything,
10660+
then use only boolean data. Not implemented for Series.
10661+
skipna : bool, default True
10662+
Exclude NA/null values. If the entire row/column is NA and skipna is
10663+
True, then the result will be %(empty_value)s, as for an empty row/column.
10664+
If skipna is False, then NA are treated as True, because these are not
10665+
equal to zero.
10666+
level : int or level name, default None
10667+
If the axis is a MultiIndex (hierarchical), count along a
10668+
particular level, collapsing into a %(name1)s.
10669+
**kwargs : any, default None
10670+
Additional keywords have no effect but might be accepted for
10671+
compatibility with NumPy.
10672+
Returns
10673+
-------
10674+
%(name1)s or %(name2)s
10675+
If level is specified, then, %(name2)s is returned; otherwise, %(name1)s
10676+
is returned.
10677+
%(see_also)s
10678+
%(examples)s"""
10679+
1062610680
_all_desc = """\
1062710681
Return whether all elements are True, potentially over an axis.
1062810682
@@ -10683,6 +10737,36 @@ def _doc_parms(cls):
1068310737
DataFrame.any : Return True if one (or more) elements are True.
1068410738
"""
1068510739

10740+
_cnum_doc = """
10741+
Return cumulative %(desc)s over a DataFrame or Series axis.
10742+
Returns a DataFrame or Series of the same size containing the cumulative
10743+
%(desc)s.
10744+
Parameters
10745+
----------
10746+
axis : {0 or 'index', 1 or 'columns'}, default 0
10747+
The index or the name of the axis. 0 is equivalent to None or 'index'.
10748+
skipna : bool, default True
10749+
Exclude NA/null values. If an entire row/column is NA, the result
10750+
will be NA.
10751+
*args, **kwargs
10752+
Additional keywords have no effect but might be accepted for
10753+
compatibility with NumPy.
10754+
Returns
10755+
-------
10756+
%(name1)s or %(name2)s
10757+
Return cumulative %(desc)s of %(name1)s or %(name2)s.
10758+
See Also
10759+
--------
10760+
core.window.Expanding.%(accum_func_name)s : Similar functionality
10761+
but ignores ``NaN`` values.
10762+
%(name2)s.%(accum_func_name)s : Return the %(desc)s over
10763+
%(name2)s axis.
10764+
%(name2)s.cummax : Return cumulative maximum over %(name2)s axis.
10765+
%(name2)s.cummin : Return cumulative minimum over %(name2)s axis.
10766+
%(name2)s.cumsum : Return cumulative sum over %(name2)s axis.
10767+
%(name2)s.cumprod : Return cumulative product over %(name2)s axis.
10768+
%(examples)s"""
10769+
1068610770
_cummin_examples = """\
1068710771
Examples
1068810772
--------
@@ -11251,32 +11335,11 @@ def stat_func(
1125111335
def _make_stat_function_ddof(
1125211336
cls, name: str, name1: str, name2: str, axis_descr: str, desc: str, func: Callable
1125311337
) -> Callable:
11254-
@doc(desc=desc, name1=name1, name2=name2, axis_descr=axis_descr)
11338+
@Substitution(desc=desc, name1=name1, name2=name2, axis_descr=axis_descr)
11339+
@Appender(_num_ddof_doc)
1125511340
def stat_func(
1125611341
self, axis=None, skipna=None, level=None, ddof=1, numeric_only=None, **kwargs
1125711342
):
11258-
"""
11259-
{desc}
11260-
11261-
Parameters
11262-
----------
11263-
axis : {axis_descr}
11264-
skipna : bool, default True
11265-
Exclude NA/null values. If an entire row/column is NA, the result
11266-
will be NA.
11267-
level : int or level name, default None
11268-
If the axis is a MultiIndex (hierarchical), count along a
11269-
particular level, collapsing into a %(name1)s.
11270-
ddof : int, default 1
11271-
Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
11272-
where N represents the number of elements.
11273-
numeric_only : bool, default None
11274-
Include only float, int, boolean columns. If None, will attempt to use
11275-
everything, then use only numeric data. Not implemented for Series.
11276-
11277-
Returns
11278-
-------
11279-
{name1} or {name2} (if level specified)\n"""
1128011343
nv.validate_stat_ddof_func(tuple(), kwargs, fname=name)
1128111344
if skipna is None:
1128211345
skipna = True
@@ -11304,48 +11367,16 @@ def _make_cum_function(
1130411367
accum_func_name: str,
1130511368
examples: str,
1130611369
) -> Callable:
11307-
@doc(
11370+
@Substitution(
1130811371
desc=desc,
1130911372
name1=name1,
1131011373
name2=name2,
11374+
axis_descr=axis_descr,
1131111375
accum_func_name=accum_func_name,
1131211376
examples=examples,
1131311377
)
11378+
@Appender(_cnum_doc)
1131411379
def cum_func(self, axis=None, skipna=True, *args, **kwargs):
11315-
"""
11316-
Return cumulative {desc} over a DataFrame or Series axis.
11317-
11318-
Returns a DataFrame or Series of the same size containing the cumulative
11319-
{desc}.
11320-
11321-
Parameters
11322-
----------
11323-
axis : {{0 or 'index', 1 or 'columns'}}, default 0
11324-
The index or the name of the axis. 0 is equivalent to None or 'index'.
11325-
skipna : bool, default True
11326-
Exclude NA/null values. If an entire row/column is NA, the result
11327-
will be NA.
11328-
*args, **kwargs
11329-
Additional keywords have no effect but might be accepted for
11330-
compatibility with NumPy.
11331-
11332-
Returns
11333-
-------
11334-
{name1} or {name2}
11335-
Return cumulative {desc} of {name1} or {name2}.
11336-
11337-
See Also
11338-
--------
11339-
core.window.Expanding.{accum_func_name} : Similar functionality
11340-
but ignores ``NaN`` values.
11341-
{name2}.{accum_func_name} : Return the {desc} over
11342-
{name2} axis.
11343-
{name2}.cummax : Return cumulative maximum over {name2} axis.
11344-
{name2}.cummin : Return cumulative minimum over {name2} axis.
11345-
{name2}.cumsum : Return cumulative sum over {name2} axis.
11346-
{name2}.cumprod : Return cumulative product over {name2} axis.
11347-
11348-
{examples}"""
1134911380
skipna = nv.validate_cum_func_with_skipna(skipna, args, kwargs, name)
1135011381
if axis is None:
1135111382
axis = self._stat_axis_number
@@ -11382,52 +11413,17 @@ def _make_logical_function(
1138211413
examples: str,
1138311414
empty_value: bool,
1138411415
) -> Callable:
11385-
@doc(
11416+
@Substitution(
1138611417
desc=desc,
1138711418
name1=name1,
1138811419
name2=name2,
11420+
axis_descr=axis_descr,
1138911421
see_also=see_also,
1139011422
examples=examples,
11391-
empty_value=str(empty_value),
11423+
empty_value=empty_value,
1139211424
)
11425+
@Appender(_bool_doc)
1139311426
def logical_func(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs):
11394-
"""
11395-
{desc}
11396-
11397-
Parameters
11398-
----------
11399-
axis : {{0 or 'index', 1 or 'columns', None}}, default 0
11400-
Indicate which axis or axes should be reduced.
11401-
11402-
* 0 / 'index' : reduce the index, return a Series whose index is the
11403-
original column labels.
11404-
* 1 / 'columns' : reduce the columns, return a Series whose index is the
11405-
original index.
11406-
* None : reduce all axes, return a scalar.
11407-
11408-
bool_only : bool, default None
11409-
Include only boolean columns. If None, will attempt to use everything,
11410-
then use only boolean data. Not implemented for Series.
11411-
skipna : bool, default True
11412-
Exclude NA/null values. If the entire row/column is NA and skipna is
11413-
True, then the result will be {empty_value}, as for an empty row/column.
11414-
If skipna is False, then NA are treated as True, because these are not
11415-
equal to zero.
11416-
level : int or level name, default None
11417-
If the axis is a MultiIndex (hierarchical), count along a
11418-
particular level, collapsing into a {name1}.
11419-
**kwargs : any, default None
11420-
Additional keywords have no effect but might be accepted for
11421-
compatibility with NumPy.
11422-
11423-
Returns
11424-
-------
11425-
{name1} or {name2}
11426-
If level is specified, then, {name2} is returned; otherwise, {name1}
11427-
is returned.
11428-
11429-
{see_also}
11430-
{examples}"""
1143111427
nv.validate_logical_func(tuple(), kwargs, fname=name)
1143211428
if level is not None:
1143311429
if bool_only is not None:

0 commit comments

Comments
 (0)