Highlight values defined by a quantile with a style.
Added in version 1.3.0.
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.
Background color to use for highlighting.
Axis along which to determine and highlight quantiles. If None quantiles are measured over the entire DataFrame. See examples.
Left bound, in [0, q_right), for the target quantile range.
Right bound, in (q_left, 1], for the target quantile range.
Argument passed to Series.quantile or DataFrame.quantile for quantile estimation.
Identify whether quantile bounds are closed or open.
CSS properties to use for highlighting. If props is given, color is not used.
See also
Styler.highlight_nullHighlight missing values with a style.
Styler.highlight_maxHighlight the maximum with a style.
Styler.highlight_minHighlight the minimum with a style.
Styler.highlight_betweenHighlight a defined range with a style.
Notes
This function does not work with str dtypes.
Examples
Using axis=None and apply a quantile to all collective data
>>> df = pd.DataFrame(np.arange(10).reshape(2,5) + 1)
>>> df.style.highlight_quantile(axis=None, q_left=0.8, color="#fffd75")
...
Or highlight quantiles row-wise or column-wise, in this case by row-wise
>>> df.style.highlight_quantile(axis=1, q_left=0.8, color="#fffd75")
...
Use props instead of default background coloring
>>> df.style.highlight_quantile(axis=None, q_left=0.2, q_right=0.8,
... props='font-weight:bold;color:#e83e8c')
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.io.formats.style.Styler.highlight_quantile.html