-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Styler.background_gradient needs to handle NaN values #14260
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
Comments
|
@stonebig Were you able to reproduce it with a simpler example? Or this the usage of the widgets, seaborn, .. needed to reproduce? |
The line Sorry, I'm not expert enough in Pandas to reduce the Jeff example. Maybe it's a too wired usage of Pandas/Seaborn/Matplotlib/Numpy ? |
Yes, but can you trigger the warning without using interact? |
Sorry, I don't know how to transform the code: if I remove interact, nothing happens |
So I get the warning with just running |
See matplotlib/matplotlib#7129 (comment) for a more detailed reproducible example |
the wired fact is that it's not failing with Pandas-0.18.1, or the error message was intercepted |
Did your numpy version change when upgrading from 0.18.1 to 0.19.0rc1? |
now I went back from Matplotlibe-2.0.0b4 to 1.5.3 then 1.5.2, and as it was doing nothing I started doing the same with Pandas. no other package were armed nor touched in the process. Maybe Jeff did a special hack for his demo, and the code has been normalized since that demo, or the ordering of operations has been changed. |
So summary of discussion in matplotlib/matplotlib#7129. The warning is caused by a line of pure numpy code, so it is not related to pandas or matplotlib. But, pandas no longers suppresses this kind of warnings starting from 0.19.0 (#13145). This is why you only see the warning with the latest pandas. But the conclusion for pandas is: matplotlib's |
after all this effort digging for the truth, it's sad the fix won't make it for Pandas 0.19 final |
PR is always welcome, and then it can be fixed in 0.19, no problem. The tag is just to indicate it is not a priority for 0.19 |
shouldn't it be tagged as a regression ? |
There is no change in behaviour, it's only a warning, so I don't think it's important enough for that. |
Note that this affects several of the examples in the styling documentation (without explanation to what is happening) https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html#Builtin-styles |
I think this remains an issue. nan should not be included in colour normalisation for background_gradient . |
is it possible to pass a boolean DataFrame as the
|
i got this to style nan as 0 in the worst way possible. this is for pandas 0.25.3 and may not work for other versions. breaks def my_render(styler, **kwargs):
# change the data before calling ._compute()
# then change it back
data = styler.data
data_copy = data.copy()
data_copy[data.isnull()] = 0
styler.data = data_copy
styler._compute()
styler.data = data
d = styler._translate()
trimmed = [x for x in d["cellstyle"] if any(any(y) for y in x["props"])]
d["cellstyle"] = trimmed
d.update(kwargs)
return styler.template.render(**d)
pd.io.formats.style.Styler.render = my_render |
This code is ok under Pandas-0.18.1 (from a @jreback demo)
With Pandas-0.19rc1, I get a warning:
see matplotlib/matplotlib#7129
The text was updated successfully, but these errors were encountered: