-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Styler tooltips feature #35643
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: Styler tooltips feature #35643
Conversation
cdaf9d9
to
1598830
Compare
@reviewers: this is ready to be reviewed. All green, except for known unrelated issues |
6a69f83
to
c18103b
Compare
c18103b
to
f798852
Compare
@TomAugspurger @WillAyd you both commented on the underlying issue. Would you care to review this pull request for suitability? |
It'll be a while before I can look. No need to hold it up for me.
…On Fri, Aug 28, 2020 at 2:10 PM attack68 ***@***.***> wrote:
@TomAugspurger <https://github.com/TomAugspurger> @WillAyd
<https://github.com/WillAyd> you both commented on the underlying issue.
Would you care to review this pull request for suitability?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#35643 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKAOIXGGVOYJUO2GU73BJ3SC76JNANCNFSM4PZFPFBQ>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks reasonable, some comments
doc/source/user_guide/style.ipynb
Outdated
@@ -1241,4 +1241,4 @@ | |||
}, | |||
"nbformat": 4, | |||
"nbformat_minor": 1 | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you revert this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've no real experience with selected git revert, doesn't it just get squashed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git checkout upstream/master doc/source/user_guide/style.ipynb
and commit the result
would be good to to have the 1.2 milestone on this and then I can work on improving the documentation for all the Styler enhancements I have contributed in subsequent minor versions.. |
apologies for posting with wrong account above: work not personal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know you really want this for 1.2, but it needs some work, if you can turn it around shortly then we can do
pandas/io/formats/style.py
Outdated
@@ -540,6 +627,7 @@ def render(self, **kwargs) -> str: | |||
self._compute() | |||
# TODO: namespace all the pandas keys | |||
d = self._translate() | |||
d = self.tooltips._translate_tooltips(self.data, self.uuid, d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very confusing here, why is this not part of _translate itself?
for style in sublist | ||
] | ||
|
||
if self.table_styles: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am puzzled by this here why this is involved at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the above table_styles
will be an empty list if there are no tooltips to add, i.e if the mask
was empty. In that case this if
check provides some efficiency by avoiding adding a <span>
html selector to every table cell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok can you add that as a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added a comment line 1938?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, some small comments. ping on green.
assume that you will do a followon to add docs to the style notebook? (can also be in this PR)
for style in sublist | ||
] | ||
|
||
if self.table_styles: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok can you add that as a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good a question and comment.
for style in sublist | ||
] | ||
|
||
if self.table_styles: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update this
ok @attack68 can you resolve this precommit issue: merge master and ping on green-ish |
…eature # Conflicts: # doc/source/whatsnew/v1.3.0.rst
a29719d
to
54c52da
Compare
@jreback fixed, green-ish... ping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @attack68
would not object to a PR to split up pandas/io/formats/style.py to submodules in the future as this file is getting kind of long / including multiple functionaility.
@jreback this broke pre-commit on master. will fix up shortly so feel free to carry on merging PRs to master |
thanks @simonjayhawkins |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
This is a draft PR to address 21266: Tooltips for DataFrames in Styler.
This PR has the following objectives:
table_styles
to control the visualisation of the tooltips.To address 1) the architecture was simple:
tooltips
are detected then an additional HTML element is added to every data cell:<span class="pd-t"></span>
. Iftooltips
are not detected (by default) nothing is done.To address 2) default values ensure the functions make no changes unless
set_tooltips
has been called.Extensions
The very simple architecture requires a DataFrame of tooltips to be supplied. This requires the user to have constructed it privately (possibly using the regular DataFrame.apply and DataFrame.applymap) methods. These could be incorporated.
It would also be better to only add extra HTML elements to data cells that have tooltips. This requires conditional looping of the render dict, which I haven't included here to save on initial complexity. For small dataframes it is also irrelevant.
However, given my time constraints I would rather leave this to a more available and more competent developer!!
Comments welcome..