How To Apply Style Frame On Individual Cells Using Apply_style_by_indexes()
is there a way to apply StyleFrame on individual cells rather than using some conditional statements to style the entire row.
Solution 1:
Yes, but it is not straightforward.
You can abuse the fact that apply_style_by_indexes
accepts a cols_to_style
argument (see the docs), and the fact that you can pass an index directly:
sf = StyleFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]})
sf.apply_style_by_indexes(sf.index[1], Styler(bg_color='yellow'), cols_to_style='b')
This will only style the cell that contains 5
because it is the "intersection" of sf.index[1]
and the b
column.
Post a Comment for "How To Apply Style Frame On Individual Cells Using Apply_style_by_indexes()"