From bf2d569eb99230500d29946f50229e395aacc2f7 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Mar 2019 08:39:54 -0800 Subject: [PATCH 1/7] Document the behavior of `axis=None` --- pandas/io/formats/style.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index c8b5dc6b9b7c0..d38266af72311 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -895,7 +895,8 @@ def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0, low, high : float compress the range by these values. axis : int or str - 1 or 'columns' for columnwise, 0 or 'index' for rowwise + 0 or 'index' for columnwise, 1 or 'columns' for rowwise, or + ``None`` for tablewise subset : IndexSlice a valid slice for ``data`` to limit the style application to text_color_threshold : float or int From eaa94ebf85798c700ba44afe8c5933a146efc8ac Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Mar 2019 09:48:13 -0800 Subject: [PATCH 2/7] Unify axis docstrings --- pandas/io/formats/style.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index d38266af72311..05bfbcc7e2991 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -894,9 +894,10 @@ def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0, matplotlib colormap low, high : float compress the range by these values. - axis : int or str - 0 or 'index' for columnwise, 1 or 'columns' for rowwise, or - ``None`` for tablewise + axis : int, str or None + apply to each column (``axis=0`` or ``'index'``) or to each row + (``axis=1`` or ``'columns'``) or to the entire DataFrame at once + with ``axis=None``. subset : IndexSlice a valid slice for ``data`` to limit the style application to text_color_threshold : float or int @@ -1152,9 +1153,10 @@ def highlight_max(self, subset=None, color='yellow', axis=0): subset : IndexSlice, default None a valid slice for ``data`` to limit the style application to color : str, default 'yellow' - axis : int, str, or None; default 0 - 0 or 'index' for columnwise (default), 1 or 'columns' for rowwise, - or ``None`` for tablewise + axis : int, str or None + apply to each column (``axis=0`` or ``'index'``) or to each row + (``axis=1`` or ``'columns'``) or to the entire DataFrame at once + with ``axis=None``. Returns ------- @@ -1172,9 +1174,10 @@ def highlight_min(self, subset=None, color='yellow', axis=0): subset : IndexSlice, default None a valid slice for ``data`` to limit the style application to color : str, default 'yellow' - axis : int, str, or None; default 0 - 0 or 'index' for columnwise (default), 1 or 'columns' for rowwise, - or ``None`` for tablewise + axis : int, str or None + apply to each column (``axis=0`` or ``'index'``) or to each row + (``axis=1`` or ``'columns'``) or to the entire DataFrame at once + with ``axis=None``. Returns ------- From 8693a01774859d343f9222aa8034c4a457726875 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Mar 2019 09:48:38 -0800 Subject: [PATCH 3/7] Add default values to axis docstrings --- pandas/io/formats/style.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 05bfbcc7e2991..66de93687aed1 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -576,7 +576,7 @@ def apply(self, func, axis=0, subset=None, **kwargs): on ``axis``), and return an object with the same shape. Must return a DataFrame with identical index and column labels when ``axis=None`` - axis : int, str or None + axis : int, str or None, default 0 apply to each column (``axis=0`` or ``'index'``) or to each row (``axis=1`` or ``'columns'``) or to the entire DataFrame at once with ``axis=None`` @@ -894,7 +894,7 @@ def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0, matplotlib colormap low, high : float compress the range by these values. - axis : int, str or None + axis : int, str or None, default 0 apply to each column (``axis=0`` or ``'index'``) or to each row (``axis=1`` or ``'columns'``) or to the entire DataFrame at once with ``axis=None``. @@ -1153,7 +1153,7 @@ def highlight_max(self, subset=None, color='yellow', axis=0): subset : IndexSlice, default None a valid slice for ``data`` to limit the style application to color : str, default 'yellow' - axis : int, str or None + axis : int, str or None, default 0 apply to each column (``axis=0`` or ``'index'``) or to each row (``axis=1`` or ``'columns'``) or to the entire DataFrame at once with ``axis=None``. @@ -1174,7 +1174,7 @@ def highlight_min(self, subset=None, color='yellow', axis=0): subset : IndexSlice, default None a valid slice for ``data`` to limit the style application to color : str, default 'yellow' - axis : int, str or None + axis : int, str or None, default 0 apply to each column (``axis=0`` or ``'index'``) or to each row (``axis=1`` or ``'columns'``) or to the entire DataFrame at once with ``axis=None``. From cffa22b25f6ff2c5c1273bf9ca23f78486d92300 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Mar 2019 09:52:43 -0800 Subject: [PATCH 4/7] Use proper punctuation in the axis docstring --- pandas/io/formats/style.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 66de93687aed1..baa8b979309aa 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -577,9 +577,9 @@ def apply(self, func, axis=0, subset=None, **kwargs): Must return a DataFrame with identical index and column labels when ``axis=None`` axis : int, str or None, default 0 - apply to each column (``axis=0`` or ``'index'``) - or to each row (``axis=1`` or ``'columns'``) or - to the entire DataFrame at once with ``axis=None`` + apply to each column (``axis=0`` or ``'index'``), to each row + (``axis=1`` or ``'columns'``), or to the entire DataFrame at once + with ``axis=None``. subset : IndexSlice a valid indexer to limit ``data`` to *before* applying the function. Consider using a pandas.IndexSlice @@ -895,8 +895,8 @@ def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0, low, high : float compress the range by these values. axis : int, str or None, default 0 - apply to each column (``axis=0`` or ``'index'``) or to each row - (``axis=1`` or ``'columns'``) or to the entire DataFrame at once + apply to each column (``axis=0`` or ``'index'``), to each row + (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. subset : IndexSlice a valid slice for ``data`` to limit the style application to @@ -1084,9 +1084,9 @@ def bar(self, subset=None, axis=0, color='#d65f5f', width=100, subset : IndexSlice, optional A valid slice for `data` to limit the style application to. axis : int, str or None, default 0 - Apply to each column (`axis=0` or `'index'`) - or to each row (`axis=1` or `'columns'`) or - to the entire DataFrame at once with `axis=None`. + apply to each column (``axis=0`` or ``'index'``), to each row + (``axis=1`` or ``'columns'``), or to the entire DataFrame at once + with ``axis=None``. color : str or 2-tuple/list If a str is passed, the color is the same for both negative and positive numbers. If 2-tuple/list is used, the @@ -1154,8 +1154,8 @@ def highlight_max(self, subset=None, color='yellow', axis=0): a valid slice for ``data`` to limit the style application to color : str, default 'yellow' axis : int, str or None, default 0 - apply to each column (``axis=0`` or ``'index'``) or to each row - (``axis=1`` or ``'columns'``) or to the entire DataFrame at once + apply to each column (``axis=0`` or ``'index'``), to each row + (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. Returns @@ -1175,8 +1175,8 @@ def highlight_min(self, subset=None, color='yellow', axis=0): a valid slice for ``data`` to limit the style application to color : str, default 'yellow' axis : int, str or None, default 0 - apply to each column (``axis=0`` or ``'index'``) or to each row - (``axis=1`` or ``'columns'``) or to the entire DataFrame at once + apply to each column (``axis=0`` or ``'index'``), to each row + (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. Returns From a6969ad2bb85bca2fcc8467bafc9ae450faa29dd Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Mar 2019 09:55:10 -0800 Subject: [PATCH 5/7] Add periods to the end of sentences --- pandas/io/formats/style.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index baa8b979309aa..e9fe060146c6f 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -899,7 +899,7 @@ def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0, (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. subset : IndexSlice - a valid slice for ``data`` to limit the style application to + a valid slice for ``data`` to limit the style application to. text_color_threshold : float or int luminance threshold for determining text color. Facilitates text visibility across varying background colors. From 0 to 1. @@ -1151,7 +1151,7 @@ def highlight_max(self, subset=None, color='yellow', axis=0): Parameters ---------- subset : IndexSlice, default None - a valid slice for ``data`` to limit the style application to + a valid slice for ``data`` to limit the style application to. color : str, default 'yellow' axis : int, str or None, default 0 apply to each column (``axis=0`` or ``'index'``), to each row @@ -1172,7 +1172,7 @@ def highlight_min(self, subset=None, color='yellow', axis=0): Parameters ---------- subset : IndexSlice, default None - a valid slice for ``data`` to limit the style application to + a valid slice for ``data`` to limit the style application to. color : str, default 'yellow' axis : int, str or None, default 0 apply to each column (``axis=0`` or ``'index'``), to each row From 9ae850000cb239a6991bdaa915f3f1a75edf4600 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Mar 2019 10:21:51 -0800 Subject: [PATCH 6/7] Update axis parameter syntax --- pandas/io/formats/style.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index e9fe060146c6f..01a929fc4f820 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -576,7 +576,7 @@ def apply(self, func, axis=0, subset=None, **kwargs): on ``axis``), and return an object with the same shape. Must return a DataFrame with identical index and column labels when ``axis=None`` - axis : int, str or None, default 0 + axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. @@ -894,7 +894,7 @@ def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0, matplotlib colormap low, high : float compress the range by these values. - axis : int, str or None, default 0 + axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. @@ -1083,7 +1083,7 @@ def bar(self, subset=None, axis=0, color='#d65f5f', width=100, ---------- subset : IndexSlice, optional A valid slice for `data` to limit the style application to. - axis : int, str or None, default 0 + axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. @@ -1153,7 +1153,7 @@ def highlight_max(self, subset=None, color='yellow', axis=0): subset : IndexSlice, default None a valid slice for ``data`` to limit the style application to. color : str, default 'yellow' - axis : int, str or None, default 0 + axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. @@ -1174,7 +1174,7 @@ def highlight_min(self, subset=None, color='yellow', axis=0): subset : IndexSlice, default None a valid slice for ``data`` to limit the style application to. color : str, default 'yellow' - axis : int, str or None, default 0 + axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. From 8b1c6f0733c649fdb8d90e36cfb03779ce149360 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Wed, 6 Mar 2019 12:04:00 -0800 Subject: [PATCH 7/7] Replace non-ascii apostrophes --- pandas/io/formats/style.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 01a929fc4f820..b872f86eb8683 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -576,7 +576,7 @@ def apply(self, func, axis=0, subset=None, **kwargs): on ``axis``), and return an object with the same shape. Must return a DataFrame with identical index and column labels when ``axis=None`` - axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 + axis : {0 or 'index', 1 or 'columns', None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. @@ -894,7 +894,7 @@ def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0, matplotlib colormap low, high : float compress the range by these values. - axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 + axis : {0 or 'index', 1 or 'columns', None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. @@ -1083,7 +1083,7 @@ def bar(self, subset=None, axis=0, color='#d65f5f', width=100, ---------- subset : IndexSlice, optional A valid slice for `data` to limit the style application to. - axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 + axis : {0 or 'index', 1 or 'columns', None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. @@ -1153,7 +1153,7 @@ def highlight_max(self, subset=None, color='yellow', axis=0): subset : IndexSlice, default None a valid slice for ``data`` to limit the style application to. color : str, default 'yellow' - axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 + axis : {0 or 'index', 1 or 'columns', None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``. @@ -1174,7 +1174,7 @@ def highlight_min(self, subset=None, color='yellow', axis=0): subset : IndexSlice, default None a valid slice for ``data`` to limit the style application to. color : str, default 'yellow' - axis : {0 or ‘index’, 1 or ‘columns’, None}, default 0 + axis : {0 or 'index', 1 or 'columns', None}, default 0 apply to each column (``axis=0`` or ``'index'``), to each row (``axis=1`` or ``'columns'``), or to the entire DataFrame at once with ``axis=None``.