Styler extremely slow · Issue #19917 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Description
Code Sample
def highlighter(col):
'''
Highlights rows in highlight_map
keys where df[highlight map
values]==1
'''
highlight_map = {
'Service Type': 'ServiceType_Added',
'Store #': 'Store_Added',
}
if col.name in highlight_map:
return ['background-color: yellow' if final[highlight_map[col.name]][v] else '' for v in col.index.tolist()]
else:
return [''] * len(col)
styled = final.style.apply(highlighter) styled.to_excel('highlights.xlsx', engine='openpyxl')
Problem description
Here I have some conditional highlighting on a df with 18k rows. The issue is that despite preceding complex operations on the df (such as conditional merges and df.apply
by row) taking ~300ms at the most, the Styler.apply
part takes over two minutes. I realize this feature is in development but I am wondering if there is a way to make it faster or if this is a known issue.