Skip to content
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

ENH: Add support for tablewise application of style.background_gradient with axis=None #21259

Merged

Conversation

soxofaan
Copy link
Contributor

@soxofaan soxofaan commented May 30, 2018

@pep8speaks
Copy link

pep8speaks commented May 30, 2018

Hello @soxofaan! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on July 11, 2018 at 15:48 Hours UTC

@soxofaan soxofaan force-pushed the issue-15204-background-axix-none branch 3 times, most recently from 060fd66 to b1dfa6c Compare May 30, 2018 16:06
@@ -901,16 +901,21 @@ def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0,
def _background_gradient(s, cmap='PuBu', low=0, high=0):
"""Color background in a range according to the data."""
with _mpl(Styler.background_gradient) as (plt, colors):
rng = s.max() - s.min()
min = s.values.min()
max = s.values.max()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use different names for min/max so they don't override the built-in min/max functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, updated commit

@jschendel jschendel added Enhancement Output-Formatting __repr__ of pandas objects, to_string labels May 30, 2018
@jschendel jschendel added this to the 0.24.0 milestone May 30, 2018
@soxofaan soxofaan force-pushed the issue-15204-background-axix-none branch from b1dfa6c to e376312 Compare May 30, 2018 21:11
@codecov
Copy link

codecov bot commented May 30, 2018

Codecov Report

Merging #21259 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #21259      +/-   ##
==========================================
+ Coverage   91.92%   91.92%   +<.01%     
==========================================
  Files         160      160              
  Lines       49906    49910       +4     
==========================================
+ Hits        45875    45879       +4     
  Misses       4031     4031
Flag Coverage Δ
#multiple 90.3% <100%> (ø) ⬆️
#single 42.1% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/io/formats/style.py 96.16% <100%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d0daa0...c39f420. Read the comment docs.

@soxofaan
Copy link
Contributor Author

@jschendel I updated the commit per your request

the failing tests/checks are not related to the change as far as I understand, is there something I should do about that?

@jreback
Copy link
Contributor

jreback commented May 31, 2018

you have linting issues:

pandas/tests/io/formats/test_style.py:1066:1: E303 too many blank lines (3)

@jreback
Copy link
Contributor

jreback commented May 31, 2018

is it worth adding the OP example here?

@soxofaan soxofaan force-pushed the issue-15204-background-axix-none branch from e6f7758 to 5c05bf1 Compare May 31, 2018 12:55
@soxofaan
Copy link
Contributor Author

@jreback thanks, I didn't catch that linting issue warning. Lot of trees in the forest.

I think the OP example is good for interactive testing, but overkill for unit testing

@soxofaan soxofaan force-pushed the issue-15204-background-axix-none branch from 5c05bf1 to 23a4bfb Compare May 31, 2018 17:00
@soxofaan
Copy link
Contributor Author

(this PR will conflict with #21263 )

@soxofaan soxofaan force-pushed the issue-15204-background-axix-none branch from 23a4bfb to 0f2b688 Compare June 7, 2018 19:12
@soxofaan
Copy link
Contributor Author

soxofaan commented Jun 7, 2018

Had to rework this PR because #21263 has been merged

note that making background_gradient compatible with axis=None enabled to simplify the relative_luminance implementation of #21263

@soxofaan
Copy link
Contributor Author

soxofaan commented Jun 7, 2018

Illustration:
screen shot 2018-06-07 at 21 17 59

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments. lgtm.

@@ -16,7 +16,9 @@ Other Enhancements
- :func:`Series.mode` and :func:`DataFrame.mode` now support the ``dropna`` parameter which can be used to specify whether NaN/NaT values should be considered (:issue:`17534`)
- :func:`to_csv` now supports ``compression`` keyword when a file handle is passed. (:issue:`21227`)
- :meth:`Index.droplevel` is now implemented also for flat indexes, for compatibility with MultiIndex (:issue:`21115`)

- Allow elementwise coloring in ``style.background_gradient`` with ``axis=None`` (:issue:`15204`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use :class:`pandas.io.formats.style.Styler`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even better, I'll move it alongside with the changelog entry for PR #21263

@soxofaan soxofaan force-pushed the issue-15204-background-axix-none branch from 5322f25 to f044cf7 Compare June 19, 2018 17:38
@soxofaan
Copy link
Contributor Author

continuous-integration/travis-ci/pr failure is due to

CondaHTTPError: HTTP 502 BAD GATEWAY for url <https://conda.anaconda.org/conda-forge/linux-64/repodata.json>

@soxofaan
Copy link
Contributor Author

😕 now continuous-integration/travis-ci/pr failure is due to

$ curl -sSf -o python-3.5.tar.bz2 ${archive_url}
curl: (35) Unknown SSL protocol error in connection to s3.amazonaws.com:443 
Unable to download 3.5 archive. The archive may not exist. Please consider a different version.

@soxofaan soxofaan changed the title ENH: Allow elementwise coloring in background_gradient with axis=None ENH: Add support for tablewise application of style.background_gradient with axis=None Jun 24, 2018
@soxofaan soxofaan force-pushed the issue-15204-background-axix-none branch from d615e90 to c39f420 Compare July 11, 2018 15:47
@soxofaan
Copy link
Contributor Author

soxofaan commented Jul 11, 2018

(rebased on latest master)

@TomAugspurger TomAugspurger merged commit bdb6168 into pandas-dev:master Jul 12, 2018
@TomAugspurger
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Allow elementwise coloring in background_gradient with axis=None
5 participants