GroupBy.pipe(func, *args, **kwargs)[source]

Apply a function with arguments to this GroupBy object,

New in version 0.21.0.


func : callable or tuple of (callable, string)

Function to apply to this GroupBy object or, alternatively, a (callable, data_keyword) tuple where data_keyword is a string indicating the keyword of callable that expects the GroupBy object.

args : iterable, optional

positional arguments passed into func.

kwargs : dict, optional

a dictionary of keyword arguments passed into func.


object : the return type of func.

See also

Apply a function with arguments to a series
Apply a function with arguments to a dataframe
Apply function to each group instead of to the full GroupBy object.


Use .pipe when 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

Scroll To Top