Table Of Contents


Enter search terms or a module, class or function name.

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

Apply func(self, *args, **kwargs), and return the result.

New in version 0.24.0.


func : function

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.

*args, **kwargs :

Arguments passed to func.


object :

The value returned by func.

See also

Analogous method for DataFrame.
Apply a function row-wise, column-wise, or table-wise to modify the dataframe’s styling.


Like DataFrame.pipe(), this method can simplify the application of several user-defined functions to a styler. Instead of writing:

f(g(, arg1=a), arg2=b, arg3=c)

users can write:

   .pipe(g, arg1=a)
   .pipe(f, arg2=b, arg3=c))

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()). Using .pipe, these user-defined style “transformations” can be interleaved with calls to the built-in Styler interface.


>>> def format_conversion(styler):
...     return (styler.set_properties(**{'text-align': 'right'})
...                   .format({'conversion': '{:.1%}'}))

The user-defined format_conversion function above can be called within a sequence of other style modifications:

>>> df = pd.DataFrame({'trial': list(range(5)),
...                    'conversion': [0.75, 0.85, np.nan, 0.7, 0.72]})
>>> (
...    .highlight_min(subset=['conversion'], color='yellow')
...    .pipe(format_conversion)
...    .set_caption("Results with minimum conversion highlighted."))
Scroll To Top