>>> styler = df.loc[[(1,1,0), (1,1,1)]].style >>> styler.hide(level=[0,1]).relabel_index(["binary6", "binary7"]) ... # doctest: +SKIP col binary6 6 binary7 7 Defining a formatting function which uses an enumeration counter. Also note that the value of the index key is passed in the case of string labels so it can also be inserted into the label, using curly brackets (or double curly brackets if the string if pre-formatted), >>> df = pd.DataFrame({"samples": np.random.rand(10)}) >>> styler = df.loc[np.random.randint(0,10,3)].style >>> styler.relabel_index([f"sample{i+1} ({{}})" for i in range(3)]) ... # doctest: +SKIP samples sample1 (5) 0.315811 sample2 (0) 0.495941 sample3 (2) 0.067946 r