pandas.io.formats.style.Styler.set_sticky

Styler.set_sticky(axis=0, pixel_size=None, levels=None)[source]

Add CSS to permanently display the index or column headers in a scrolling frame.

Parameters
axis:{0 or ‘index’, 1 or ‘columns’}, default 0

Whether to make the index or column headers sticky.

pixel_size:int, optional

Required to configure the width of index cells or the height of column header cells when sticking a MultiIndex (or with a named Index). Defaults to 75 and 25 respectively.

levels:list of int

If axis is a MultiIndex the specific levels to stick. If None will stick all levels.

Returns
self:Styler

Notes

This method uses the CSS ‘position: sticky;’ property to display. It is designed to work with visible axes, therefore both:

  • styler.set_sticky(axis=”index”).hide_index()

  • styler.set_sticky(axis=”columns”).hide_columns()

may produce strange behaviour due to CSS controls with missing elements.

© 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_sticky.html