pipe(self, func: 'Callable[..., T] | tuple[Callable[..., T], str]', *args, **kwargs) -> 'T'
Use .pipe
when chaining together functions that expect Series, DataFrames or GroupBy objects. Instead of writing
>>> func(g(h(df), arg1=a), arg2=b, arg3=c) # doctest: +SKIP
You can write
>>> (df.pipe(h) ... .pipe(g, arg1=a) ... .pipe(func, arg2=b, arg3=c) ... ) # doctest: +SKIP
If you have a function that takes the data as (say) the second argument, pass a tuple indicating which keyword expects the data. For example, suppose f
takes its data as arg2
:
>>> (df.pipe(h) ... .pipe(g, arg1=a) ... .pipe((func, 'arg2'), arg1=a, arg3=c) ... ) # doctest: +SKIP
Function to apply to the Series/DataFrame. args
, and kwargs
are passed into func
. Alternatively a (callable, data_keyword)
tuple where data_keyword
is a string indicating the keyword of callable
that expects the Series/DataFrame.
Positional arguments passed into func
.
A dictionary of keyword arguments passed into func
.
Apply chainable functions that expect Series or DataFrames.
DataFrame.apply
Apply a function along input axis of DataFrame.
DataFrame.applymap
Apply a function elementwise on a whole DataFrame.
Series.map
Apply a mapping correspondence on a :None:class:`~pandas.Series`
.
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them