cudf.core.groupby.groupby.GroupBy.pipe#
- GroupBy.pipe(func, *args, **kwargs)[source]#
Apply a function func with arguments to this GroupBy object and return the function’s result.
- Parameters:
- funcfunction
Function to apply to this GroupBy object or, alternatively, a
(callable, data_keyword)
tuple wheredata_keyword
is a string indicating the keyword ofcallable
that expects the GroupBy object.- argsiterable, optional
Positional arguments passed into
func
.- kwargsmapping, optional
A dictionary of keyword arguments passed into
func
.
- Returns:
- objectthe return type of
func
.
- objectthe return type of
See also
cudf.Series.pipe
Apply a function with arguments to a series.
cudf.DataFrame.pipe
Apply a function with arguments to a dataframe.
apply
Apply function to each group instead of to the full GroupBy object.
Examples
>>> import cudf >>> df = cudf.DataFrame({'A': ['a', 'b', 'a', 'b'], 'B': [1, 2, 3, 4]}) >>> df A B 0 a 1 1 b 2 2 a 3 3 b 4
To get the difference between each groups maximum and minimum value in one pass, you can do
>>> df.groupby('A', sort=True).pipe(lambda x: x.max() - x.min()) B A a 2 b 2