pandas.io.formats.style.Styler.set_properties

Styler.set_properties(subset=None, **kwargs)[source]

Set defined CSS-properties to each <td> HTML element within the given subset.

Parameters
subset:label, array-like, IndexSlice, optional

A valid 2d input to DataFrame.loc[<subset>], or, in the case of a 1d input or single key, to DataFrame.loc[:, <subset>] where the columns are prioritised, to limit data to before applying the function.

**kwargs:dict

A dictionary of property, value pairs to be set for each cell.

Returns
self:Styler

Notes

This is a convenience methods which wraps the Styler.applymap() calling a function returning the CSS-properties independently of the data.

Examples

>>> df = pd.DataFrame(np.random.randn(10, 4))
>>> df.style.set_properties(color="white", align="right")
>>> df.style.set_properties(**{'background-color': 'yellow'})

© 2008–2021, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.3.4/reference/api/pandas.io.formats.style.Styler.set_properties.html