MCPcopy
hub / github.com/pandas-dev/pandas / _python_apply_general

Method _python_apply_general

pandas/core/groupby/groupby.py:1653–1696  ·  view source on GitHub ↗

Apply function f in python space Parameters ---------- f : callable Function to apply data : Series or DataFrame Data to apply f to not_indexed_same: bool, optional When specified, overrides the value of not_indexe

(
        self,
        f: Callable,
        data: DataFrame | Series,
        not_indexed_same: bool | None = None,
        is_transform: bool = False,
        is_agg: bool = False,
    )

Source from the content-addressed store, hash-verified

1651
1652 @final
1653 def _python_apply_general(
1654 self,
1655 f: Callable,
1656 data: DataFrame | Series,
1657 not_indexed_same: bool | None = None,
1658 is_transform: bool = False,
1659 is_agg: bool = False,
1660 ) -> NDFrameT:
1661 """
1662 Apply function f in python space
1663
1664 Parameters
1665 ----------
1666 f : callable
1667 Function to apply
1668 data : Series or DataFrame
1669 Data to apply f to
1670 not_indexed_same: bool, optional
1671 When specified, overrides the value of not_indexed_same. Apply behaves
1672 differently when the result index is equal to the input index, but
1673 this can be coincidental leading to value-dependent behavior.
1674 is_transform : bool, default False
1675 Indicator for whether the function is actually a transform
1676 and should not have group keys prepended.
1677 is_agg : bool, default False
1678 Indicator for whether the function is an aggregation. When the
1679 result is empty, we don't want to warn for this case.
1680 See _GroupBy._python_agg_general.
1681
1682 Returns
1683 -------
1684 Series or DataFrame
1685 data after applying f
1686 """
1687 values, mutated = self._grouper.apply_groupwise(f, data)
1688 if not_indexed_same is None:
1689 not_indexed_same = mutated
1690
1691 return self._wrap_applied_output(
1692 data,
1693 values,
1694 not_indexed_same,
1695 is_transform,
1696 )
1697
1698 @final
1699 def _agg_general(

Callers 10

_op_via_applyMethod · 0.95
applyMethod · 0.95
describeMethod · 0.95
shiftMethod · 0.95
pct_changeMethod · 0.95
__call__Method · 0.80
attrMethod · 0.80
nlargestMethod · 0.80
nsmallestMethod · 0.80
_python_agg_generalMethod · 0.80

Calls 2

_wrap_applied_outputMethod · 0.95
apply_groupwiseMethod · 0.80

Tested by

no test coverage detected