pandas.core.groupby.GroupBy.pipe
-
GroupBy.pipe(func, *args, **kwargs)[source] -
Apply a function with arguments to this GroupBy object,
New in version 0.21.0.
Parameters: func : callable or tuple of (callable, string)
Function to apply to this GroupBy object or, alternatively, a
(callable, data_keyword)tuple wheredata_keywordis a string indicating the keyword ofcallablethat expects the GroupBy object.args : iterable, optional
positional arguments passed into
func.kwargs : dict, optional
a dictionary of keyword arguments passed into
func.Returns: object : the return type of
func.See also
-
pandas.Series.pipe - Apply a function with arguments to a series
-
pandas.DataFrame.pipe - Apply a function with arguments to a dataframe
-
apply - Apply function to each group instead of to the full GroupBy object.
Notes
Use
.pipewhen chaining together functions that expect Series, DataFrames or GroupBy objects. Instead of writing>>> f(g(h(df.groupby('group')), arg1=a), arg2=b, arg3=c)You can write
>>> (df ... .groupby('group') ... .pipe(f, arg1) ... .pipe(g, arg2) ... .pipe(h, arg3))See more here
-
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.21.1/generated/pandas.core.groupby.GroupBy.pipe.html