diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 50310a3af9661..1eeb39d428ee3 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -101,10 +101,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.io.formats.style.Styler.apply_index \ pandas.io.formats.style.Styler.map_index \ pandas.io.formats.style.Styler.format \ - pandas.io.formats.style.Styler.format_index \ - pandas.io.formats.style.Styler.relabel_index \ - pandas.io.formats.style.Styler.hide \ - pandas.io.formats.style.Styler.set_td_classes \ pandas.io.formats.style.Styler.set_tooltips \ pandas.io.formats.style.Styler.set_uuid \ pandas.io.formats.style.Styler.pipe \ @@ -114,9 +110,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.io.formats.style.Styler.text_gradient \ pandas.DataFrame.values \ pandas.DataFrame.groupby \ - pandas.DataFrame.idxmax \ - pandas.DataFrame.idxmin \ - pandas.DataFrame.pivot \ pandas.DataFrame.sort_values \ pandas.DataFrame.plot.hexbin \ pandas.DataFrame.plot.line \ diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 26349dc129361..0fbfae22f4663 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -1496,10 +1496,10 @@ def set_td_classes(self, classes: DataFrame) -> Styler: Using `MultiIndex` columns and a `classes` `DataFrame` as a subset of the underlying, - >>> df = pd.DataFrame([[1,2],[3,4]], index=["a", "b"], - ... columns=[["level0", "level0"], ["level1a", "level1b"]]) + >>> df = pd.DataFrame([[1, 2], [3, 4]], index=["a", "b"], + ... columns=[["level0", "level0"], ["level1a", "level1b"]]) >>> classes = pd.DataFrame(["min-val"], index=["a"], - ... columns=[["level0"],["level1a"]]) + ... columns=[["level0"], ["level1a"]]) >>> df.style.set_td_classes(classes) # doctest: +SKIP Form of the output with new additional css classes, @@ -2717,7 +2717,7 @@ def hide( -------- Simple application hiding specific rows: - >>> df = pd.DataFrame([[1,2], [3,4], [5,6]], index=["a", "b", "c"]) + >>> df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], index=["a", "b", "c"]) >>> df.style.hide(["a", "b"]) # doctest: +SKIP 0 1 c 5 6 @@ -2725,7 +2725,7 @@ def hide( Hide the index and retain the data values: >>> midx = pd.MultiIndex.from_product([["x", "y"], ["a", "b", "c"]]) - >>> df = pd.DataFrame(np.random.randn(6,6), index=midx, columns=midx) + >>> df = pd.DataFrame(np.random.randn(6, 6), index=midx, columns=midx) >>> df.style.format("{:.1f}").hide() # doctest: +SKIP x y a b c a b c @@ -2739,7 +2739,7 @@ def hide( Hide specific rows in a MultiIndex but retain the index: >>> df.style.format("{:.1f}").hide(subset=(slice(None), ["a", "c"])) - ... # doctest: +SKIP + ... # doctest: +SKIP x y a b c a b c x b 0.7 1.0 1.3 1.5 -0.0 -0.2 @@ -2748,7 +2748,7 @@ def hide( Hide specific rows and the index through chaining: >>> df.style.format("{:.1f}").hide(subset=(slice(None), ["a", "c"])).hide() - ... # doctest: +SKIP + ... # doctest: +SKIP x y a b c a b c 0.7 1.0 1.3 1.5 -0.0 -0.2 diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 55541e5262719..622e047b9f99b 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -1318,9 +1318,10 @@ def format_index( Using the default ``formatter`` for unspecified levels >>> df = pd.DataFrame([[1, 2, 3]], - ... columns=pd.MultiIndex.from_arrays([["a", "a", "b"],[2, np.nan, 4]])) + ... columns=pd.MultiIndex.from_arrays( + ... [["a", "a", "b"], [2, np.nan, 4]])) >>> df.style.format_index({0: lambda v: v.upper()}, axis=1, precision=1) - ... # doctest: +SKIP + ... # doctest: +SKIP A B 2.0 nan 4.0 0 1 2 3 @@ -1329,7 +1330,7 @@ def format_index( >>> func = lambda s: 'STRING' if isinstance(s, str) else 'FLOAT' >>> df.style.format_index(func, axis=1, na_rep='MISS') - ... # doctest: +SKIP + ... # doctest: +SKIP STRING STRING FLOAT MISS FLOAT 0 1 2 3 @@ -1338,7 +1339,7 @@ def format_index( >>> df = pd.DataFrame([[1, 2, 3]], columns=['"A"', 'A&B', None]) >>> s = df.style.format_index('$ {0}', axis=1, escape="html", na_rep="NA") - ... # doctest: +SKIP + ... # doctest: +SKIP $ "A" $ A&B NA @@ -1348,7 +1349,7 @@ def format_index( >>> df = pd.DataFrame([[1, 2, 3]], columns=["123", "~", "$%#"]) >>> df.style.format_index("\\textbf{{{}}}", escape="latex", axis=1).to_latex() - ... # doctest: +SKIP + ... # doctest: +SKIP \begin{tabular}{lrrr} {} & {\textbf{123}} & {\textbf{\textasciitilde }} & {\textbf{\$\%\#}} \\ 0 & 1 & 2 & 3 \\ @@ -1475,7 +1476,7 @@ def relabel_index( Chaining with pre-hidden elements - >>> df.style.hide([0,1]).relabel_index(["C"]) # doctest: +SKIP + >>> df.style.hide([0, 1]).relabel_index(["C"]) # doctest: +SKIP col C c @@ -1493,9 +1494,10 @@ def relabel_index( 1 5 1 0 6 1 7 - >>> styler.hide((midx.get_level_values(0)==0)|(midx.get_level_values(1)==0)) - ... # doctest: +SKIP - >>> styler.hide(level=[0,1]) # doctest: +SKIP + >>> styler.hide((midx.get_level_values(0) == 0) | + ... (midx.get_level_values(1) == 0)) + ... # doctest: +SKIP + >>> styler.hide(level=[0, 1]) # doctest: +SKIP >>> styler.relabel_index(["binary6", "binary7"]) # doctest: +SKIP col binary6 6 @@ -1503,9 +1505,9 @@ def relabel_index( We can also achieve the above by indexing first and then re-labeling - >>> styler = df.loc[[(1,1,0), (1,1,1)]].style - >>> styler.hide(level=[0,1]).relabel_index(["binary6", "binary7"]) - ... # doctest: +SKIP + >>> 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 @@ -1516,9 +1518,9 @@ def relabel_index( 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 = df.loc[np.random.randint(0, 10, 3)].style >>> styler.relabel_index([f"sample{i+1} ({{}})" for i in range(3)]) - ... # doctest: +SKIP + ... # doctest: +SKIP samples sample1 (5) 0.315811 sample2 (0) 0.495941