Apply func(self,*args,**kwargs), and return the result.
Parameters:
funcfunction
Function to apply to the Styler. Alternatively, a
(callable,keyword) tuple where keyword is a string
indicating the keyword of callable that expects the Styler.
*argsoptional
Arguments passed to func.
**kwargsoptional
A dictionary of keyword arguments passed into func.
In particular, this allows users to define functions that take a
styler object, along with other parameters, and return the styler after
making styling changes (such as calling Styler.apply() or
Styler.set_properties()).
Examples
Common Use
A common usage pattern is to pre-define styling operations which
can be easily applied to a generic styler in a single pipe call.
Sometimes it may be necessary to pre-define styling functions, but in the case
where those functions rely on the styler, data or context. Since
Styler.use and Styler.export are designed to be non-data dependent,
they cannot be used for this purpose. Additionally the Styler.apply
and Styler.format type methods are not context aware, so a solution
is to use pipe to dynamically wrap this functionality.
Suppose we want to code a generic styling function that highlights the final
level of a MultiIndex. The number of levels in the Index is dynamic so we
need the Styler context to define the level.
Additionally suppose we want to highlight a column header if there is any
missing data in that column.
In this case we need the data object itself to determine the effect on the
column headers.