Skip to content

DOC: fix EX03 errors in docstrings - pandas.io.formats.style.Styler: highlight_quantile, background_gradient, text_gradient #56904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
19 changes: 10 additions & 9 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
Expand Down