From 1c4d3643e8dcb7e4dc5d25aaa7bac1f1fc94571b Mon Sep 17 00:00:00 2001 From: Jordan Murphy <35613487+jordan-d-murphy@users.noreply.github.com> Date: Mon, 15 Jan 2024 21:31:51 -0600 Subject: [PATCH] DOC: fix EX03 errors in docstrings - pandas.io.formats.style.Styler: highlight_quantile, background_gradient, text_gradient --- ci/code_checks.sh | 3 --- pandas/io/formats/style.py | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 145be3e52f2c0..ef9a2f34bc879 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -88,9 +88,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.io.formats.style.Styler.set_uuid \ pandas.io.formats.style.Styler.pipe \ pandas.io.formats.style.Styler.highlight_between \ - pandas.io.formats.style.Styler.highlight_quantile \ - pandas.io.formats.style.Styler.background_gradient \ - pandas.io.formats.style.Styler.text_gradient \ pandas.DataFrame.values \ pandas.DataFrame.groupby \ pandas.DataFrame.sort_values \ diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 5289a21adfbb4..d0a87a3ed7f44 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -2951,17 +2951,17 @@ def background_gradient( Setting a ``gmap`` and applying to all columns with another ``cmap`` >>> df.style.{name}_gradient(axis=0, gmap=df['Temp (c)'], cmap='YlOrRd') - ... # doctest: +SKIP + ... # doctest: +SKIP .. figure:: ../../_static/style/{image_prefix}_gmap.png Setting the gradient map for a dataframe (i.e. ``axis=None``), we need to explicitly state ``subset`` to match the ``gmap`` shape - >>> gmap = np.array([[1,2,3], [2,3,4], [3,4,5]]) - >>> df.style.{name}_gradient(axis=None, gmap=gmap, - ... cmap='YlOrRd', subset=['Temp (c)', 'Rain (mm)', 'Wind (m/s)'] - ... ) # doctest: +SKIP + >>> gmap = np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) + >>> df.style.{name}_gradient( + ... axis=None, gmap=gmap, cmap='YlOrRd', + ... subset=['Temp (c)', 'Rain (mm)', 'Wind (m/s)']) # doctest: +SKIP .. figure:: ../../_static/style/{image_prefix}_axNone_gmap.png """ @@ -3507,22 +3507,23 @@ def highlight_quantile( -------- Using ``axis=None`` and apply a quantile to all collective data - >>> df = pd.DataFrame(np.arange(10).reshape(2,5) + 1) + >>> df = pd.DataFrame(np.arange(10).reshape(2, 5) + 1) >>> df.style.highlight_quantile(axis=None, q_left=0.8, color="#fffd75") - ... # doctest: +SKIP + ... # doctest: +SKIP .. figure:: ../../_static/style/hq_axNone.png Or highlight quantiles row-wise or column-wise, in this case by row-wise >>> df.style.highlight_quantile(axis=1, q_left=0.8, color="#fffd75") - ... # doctest: +SKIP + ... # doctest: +SKIP .. figure:: ../../_static/style/hq_ax1.png Use ``props`` instead of default background coloring - >>> df.style.highlight_quantile(axis=None, q_left=0.2, q_right=0.8, + >>> df.style.highlight_quantile( + ... axis=None, q_left=0.2, q_right=0.8, ... props='font-weight:bold;color:#e83e8c') # doctest: +SKIP .. figure:: ../../_static/style/hq_props.png