如何在 pandas 中给定行索引和列名称的特定单元格上色?
问题内容
我有一个形状为 (100,10) 的数据框 df 和每行的字典 columns_to_color 。
columns_to_color = { 0: ['col1', 'col2', 'col9'], # Columns 1, 2 and 9 should be colored for row 0 1: ['col1', 'col5', 'col8'], # Columns 1, 5 and 8 should be colored for row 1 2: ['col3', 'col4', 'col7'], # Columns 3, 4 and 7 should be colored for row 2 .......登录后复制