BUG+DOC: Recent Styler Enhancements by attack68 · Pull Request #39317 · pandas-dev/pandas (original) (raw)
DOC: this edits the style.ipynb
file to include examples of the 3 recent enhancements to Styler
:
- Tooltips
- External CSS classes to datacells
- Row and Column styling via table styles
It also addresses 3 minor bugs that I detected when wirting the documentation:
BUG1 (lines 696-703): set_td_classes
only attached classes to 'diagonal elements' of the DataFrame due a misaligned comprehension loop:
{
r: {
c: [str(classes.iloc[r, c])]
for c, cn in enumerate(classes.columns) if not mask.iloc[r, c]
}
for r, rn in enumerate(classes.index)
}
replaces:
{
r: {
c: [str(classes.iloc[r, c])]
}
for r, rn in enumerate(classes.index)
for c, cn in enumerate(classes.columns)
if not mask.iloc[r, c]
}
BUG2 (lines 513 to 537): external css class names from the set_td_classes were appended to the HTML id tag, as well as the HTML class tag, due to a premature variable update relating to the row_dict
. The solution was to re-order so that 'id' tags were generated first and then 'class' was updated with information from the new methods.
BUG3 (lines 1920-1925): Tooltips were generated for the wrong indexes/columns, since the null rows/columns were dropped and then the interger locations of rows/columns was mapped. The solution was to avoid dropping null rows/columns.