0

I have a webserver that displays tables of data with some formatting. The formatting is colouring certain cells. The tables are stored as dataframes and the formatting is applied using a pandas styler.

The issue is for large tables, ~3000 rows, some of the cells are not being coloured, particularly ones far down near the end of the table. I downloaded the styled dataframe as an excel sheet and the colouring was correct so I know my colouring function is correct.

When I produced a table of ~5000 rows, I noticed that the styling ends abruptly at row 4096. I think that because of the way pandas is generating the style function, web-browsers can't handle the recursive depth. Since it puts all the tags on a single CSS element like so:

#T_394319f6_5c20_11eb_832b_04ed338ce712row0_col6,#T_394319f6_5c20_11eb_832b_04ed338ce712row0_col7, 
...
#T_394319f6_5c20_11eb_832b_04ed338ce712row1_col6 { background-colour: red }

What can I do?

EDIT: Temporary solution is to colour with a random shade of the color, so I selected multiple shades of possible red for the background that are randomly selected. This "works" but is quite hacky.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57

1 Answers1

0

The latest pandas docs describe optimization of pandas styling suggesting workarounds for large dataframes.

Essentially, some browsers cannot render more than a specific number of element ids controlled by CSS. I think Chrome was a problem from memory, even though the correct HTML is generated. Some browsers render correctly.

Attack68
  • 4,437
  • 1
  • 20
  • 40