-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
[Enhancement Request] Styler support for tooltips. #21266
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
Hmm what information would you expect to appear in a tooltip? |
I was just expecting to give an arbitrary string to display (or maybe html). The basic idea is that I am styling some cells differently to highlight them, and I'd like the tooltip to give the specific reason why that cell is highlighted in precise terms. e.g. the cell is greater than a certain threshold, and the tooltip shows the precise threshold for that cell. |
This seems reasonable. A full example of what you want to achieve, and a proposed API (write the docstring) would be helpful here. |
I think the most obvious implementation of the api is just copy the styling functions, but for tooltips. For example:
Where the maximum elements of a column would get a tooltip, as well as any elements over the given threshold. (Probably you would want to style these elements differently as well to make it clear that there is a tooltip, but I didn't want to complicate the example). If this is the direction you want to go, I could write up a docstring for these functions, although it would most be just copied from the css styling functions. |
Seems reasonable. I would favor |
Laying out possible scope for development here: It is possible to create a simple tooltip by adding a html tag to any cell value that requires it. For example consider the following table:
To make this tooltip work we need to set CSS in two places. First we need the generic
And secondly the individual cell will need its own selector to activate the tooltip when hovered over. I.e. the cell should have:
This will generate a CSS style that looks like this:
To integrate this into the existing format I would suggest At render time the styles will have been added prior to constructing the render dict (so that they are captured) but the addition of the HTML elements need new functionality to be inserted to the render dict just before passing to the templating engine, by looping over the I.e. this can be done here:
The advantage of this integration is that it is also decoupled from the rest of the code and utilises the existing architecture. Additional functions like |
Problem description
It would be nice if pandas stlying allowed you to set a tooltip for table cells, in the same way that it allows you to set the CSS style using apply, applymap, etc.
Currently it is possible to create a hacky workaround using css-only tooltips and set_table_styles, but it adds substantial complexity to achieve something that is conceptually very simple.
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-6-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 36.0.1
Cython: 0.28.3
numpy: 1.14.3
scipy: 0.19.1
statsmodels: 0.8.0
xarray: None
IPython: 5.1.0
sphinx: None
patsy: 0.4.1+dev
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.2
matplotlib: 2.0.0
openpyxl: 2.3.0
xlrd: 1.1.0
xlwt: 0.7.5
xlsxwriter: None
lxml: 4.0.0
bs4: 4.6.0
html5lib: 0.999999999
httplib2: 0.9.2
apiclient: 1.6.5
sqlalchemy: 1.1.3
pymysql: 0.6.1.None
psycopg2: None
jinja2: 2.8
boto: 2.48.0
pandas_datareader: 0.2.0
The text was updated successfully, but these errors were encountered: