@@ -1318,9 +1318,10 @@ def format_index(
13181318 Using the default ``formatter`` for unspecified levels
13191319
13201320 >>> df = pd.DataFrame([[1, 2, 3]],
1321- ... columns=pd.MultiIndex.from_arrays([["a", "a", "b"],[2, np.nan, 4]]))
1321+ ... columns=pd.MultiIndex.from_arrays(
1322+ ... [["a", "a", "b"], [2, np.nan, 4]]))
13221323 >>> df.style.format_index({0: lambda v: v.upper()}, axis=1, precision=1)
1323- ... # doctest: +SKIP
1324+ ... # doctest: +SKIP
13241325 A B
13251326 2.0 nan 4.0
13261327 0 1 2 3
@@ -1329,7 +1330,7 @@ def format_index(
13291330
13301331 >>> func = lambda s: 'STRING' if isinstance(s, str) else 'FLOAT'
13311332 >>> df.style.format_index(func, axis=1, na_rep='MISS')
1332- ... # doctest: +SKIP
1333+ ... # doctest: +SKIP
13331334 STRING STRING
13341335 FLOAT MISS FLOAT
13351336 0 1 2 3
@@ -1338,7 +1339,7 @@ def format_index(
13381339
13391340 >>> df = pd.DataFrame([[1, 2, 3]], columns=['"A"', 'A&B', None])
13401341 >>> s = df.style.format_index('$ {0}', axis=1, escape="html", na_rep="NA")
1341- ... # doctest: +SKIP
1342+ ... # doctest: +SKIP
13421343 <th .. >$ "A"</th>
13431344 <th .. >$ A&B</th>
13441345 <th .. >NA</td>
@@ -1348,7 +1349,7 @@ def format_index(
13481349
13491350 >>> df = pd.DataFrame([[1, 2, 3]], columns=["123", "~", "$%#"])
13501351 >>> df.style.format_index("\\textbf{{{}}}", escape="latex", axis=1).to_latex()
1351- ... # doctest: +SKIP
1352+ ... # doctest: +SKIP
13521353 \begin{tabular}{lrrr}
13531354 {} & {\textbf{123}} & {\textbf{\textasciitilde }} & {\textbf{\$\%\#}} \\
13541355 0 & 1 & 2 & 3 \\
@@ -1475,7 +1476,7 @@ def relabel_index(
14751476
14761477 Chaining with pre-hidden elements
14771478
1478- >>> df.style.hide([0,1]).relabel_index(["C"]) # doctest: +SKIP
1479+ >>> df.style.hide([0, 1]).relabel_index(["C"]) # doctest: +SKIP
14791480 col
14801481 C c
14811482
@@ -1493,19 +1494,20 @@ def relabel_index(
14931494 1 5
14941495 1 0 6
14951496 1 7
1496- >>> styler.hide((midx.get_level_values(0)==0)|(midx.get_level_values(1)==0))
1497- ... # doctest: +SKIP
1498- >>> styler.hide(level=[0,1]) # doctest: +SKIP
1497+ >>> styler.hide((midx.get_level_values(0) == 0) |
1498+ ... (midx.get_level_values(1) == 0))
1499+ ... # doctest: +SKIP
1500+ >>> styler.hide(level=[0, 1]) # doctest: +SKIP
14991501 >>> styler.relabel_index(["binary6", "binary7"]) # doctest: +SKIP
15001502 col
15011503 binary6 6
15021504 binary7 7
15031505
15041506 We can also achieve the above by indexing first and then re-labeling
15051507
1506- >>> styler = df.loc[[(1,1, 0), (1,1, 1)]].style
1507- >>> styler.hide(level=[0,1]).relabel_index(["binary6", "binary7"])
1508- ... # doctest: +SKIP
1508+ >>> styler = df.loc[[(1, 1, 0), (1, 1, 1)]].style
1509+ >>> styler.hide(level=[0, 1]).relabel_index(["binary6", "binary7"])
1510+ ... # doctest: +SKIP
15091511 col
15101512 binary6 6
15111513 binary7 7
@@ -1516,9 +1518,9 @@ def relabel_index(
15161518 brackets if the string if pre-formatted),
15171519
15181520 >>> df = pd.DataFrame({"samples": np.random.rand(10)})
1519- >>> styler = df.loc[np.random.randint(0,10,3)].style
1521+ >>> styler = df.loc[np.random.randint(0, 10, 3)].style
15201522 >>> styler.relabel_index([f"sample{i+1} ({{}})" for i in range(3)])
1521- ... # doctest: +SKIP
1523+ ... # doctest: +SKIP
15221524 samples
15231525 sample1 (5) 0.315811
15241526 sample2 (0) 0.495941
0 commit comments