Styler.format_index_names(formatter=None, axis=0, level=None, na_rep=None, precision=None, decimal='.', thousands=None, escape=None, hyperlinks=None)[source]#

Format the text display value of index names or column names.

Added in version 3.0.

formatterstr, callable, dict or None

Object to define how values are displayed. See notes.

axis{0, “index”, 1, “columns”}

Whether to apply the formatter to the index or column headers.

levelint, str, list

The level(s) over which to apply the generic formatter.

na_repstr, optional

Representation for missing values. If na_rep is None, no special formatting is applied.

precisionint, optional

Floating point precision to use for display purposes, if not determined by the specified formatter.

decimalstr, default “.”

Character used as decimal separator for floats, complex and integers.

thousandsstr, optional, default None

Character used as thousands separator for floats, complex and integers.

escapestr, optional

Use ‘html’ to replace the characters &, <, >, ', and " in cell display string with HTML-safe sequences. Use ‘latex’ to replace the characters &, %, $, #, _, {, }, ~, ^, and \ in the cell display string with LaTeX-safe sequences. Escaping is done before formatter.

hyperlinks{“html”, “latex”}, optional

Convert string patterns containing https://, http://, ftp:// or www. to HTML <a> tags as clickable URL hyperlinks if “html”, or LaTeX href commands if “latex”.


Returns itself for chaining.


If the formatter is a string and the dtypes are incompatible.

See also


Format the text display value of index labels or column headers.


This method has a similar signature to Styler.format_index(). Since names are generally label based, and often not numeric, the typical features expected to be more frequently used here are escape and hyperlinks.


Styler.format_index_names is ignored when using the output format Styler.to_excel, since Excel and Python have inherrently different formatting structures.


>>> df = pd.DataFrame(
...     [[1, 2], [3, 4]],
...     index=pd.Index(["a", "b"], name="idx"),
... )
>>> df  
     0  1
a    1  2
b    3  4
>>> x: x.upper(), axis=0)  
     0  1
a    1  2
b    3  4