ndas.io.formats.style.Styler.set_uuid ](pandas.io.formats.style.Styler.set_uuid.html)
    * [ pandas.io.formats.style.Styler.clear ](pandas.io.formats.style.Styler.clear.html)
    * [ pandas.io.formats.style.Styler.pipe ](pandas.io.formats.style.Styler.pipe.html)
    * [ pandas.io.formats.style.Styler.highlight_null ](pandas.io.formats.style.Styler.highlight_null.html)
    * [ pandas.io.formats.style.Styler.highlight_max ](pandas.io.formats.style.Styler.highlight_max.html)
    * [ pandas.io.formats.style.Styler.highlight_min ](pandas.io.formats.style.Styler.highlight_min.html)
    * [ pandas.io.formats.style.Styler.highlight_between ](pandas.io.formats.style.Styler.highlight_between.html)
    * [ pandas.io.formats.style.Styler.highlight_quantile ](pandas.io.formats.style.Styler.highlight_quantile.html)
    * [ pandas.io.formats.style.Styler.background_gradient ](pandas.io.formats.style.Styler.background_gradient.html)
    * [ pandas.io.formats.style.Styler.text_gradient ](pandas.io.formats.style.Styler.text_gradient.html)
    * [ pandas.io.formats.style.Styler.bar ](pandas.io.formats.style.Styler.bar.html)
    * [ pandas.io.formats.style.Styler.to_html ](pandas.io.formats.style.Styler.to_html.html)
    * [ pandas.io.formats.style.Styler.to_latex ](pandas.io.formats.style.Styler.to_latex.html)
    * [ pandas.io.formats.style.Styler.to_excel ](pandas.io.formats.style.Styler.to_excel.html)
    * [ pandas.io.formats.style.Styler.to_string ](pandas.io.formats.style.Styler.to_string.html)
    * [ pandas.io.formats.style.Styler.export ](pandas.io.formats.style.Styler.export.html)
    * [ pandas.io.formats.style.Styler.use ](pandas.io.formats.style.Styler.use.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ Style ](../style.html)
  * pandas.io.fo... 

#  pandas.io.formats.style.Styler.set_sticky  #

Styler.  set_sticky  (  _ axis  =  0  _ , _ pixel_size  =  None  _ , _ levels
=  None  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/io/formats/style.py#L2349-L2487) #

    

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** int, str, list, optional

    

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

Returns  :

    

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(axis=âindexâ)
>
>   * styler.set_sticky(axis=âcolumnsâ).hide(axis=âcolumnsâ)
>
>

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

Examples

    
    
    >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
    >>> df.style.set_sticky(axis="index")  
    

Please see: [ Table Visualization  ](../../user_guide/style.html) for more
examples.

[ __ previous  pandas.io.formats.style.Styler.set_caption
](pandas.io.formats.style.Styler.set_caption.html "previous page") [ next
pandas.io.formats.style.Styler.set_properties  __
](pandas.io.formats.style.Styler.set_properties.html "next page")

__ On this page

  * ` Styler.set_sticky()  `

[ __ Show Source
](../../_sources/reference/api/pandas.io.formats.style.Styler.set_sticky.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built wi