How to colour individual array entries in a DataFrame cell with PrettyTables or similar?

Olegg
Thu, 27 Jul 2023 14:02:07 +0000
General Usage

I have a many-column DataFrames with most columns containing an array in each cell. (These are properties per solution in multi-constrained optimisation.) Here’s a snippet with 3-element arrays

Would it be possible to colour negative array elements in Red, and perhaps assign another colour to elements for a grossly violated constraint?

In the PrettyTables package (which is awesome!) I only see how to Highlight the whole array.

Another option — split an array column into scalar subcolumns — seems unwieldy for a wide table

There’s the LaTeX backend in PrettyTables, but I’d like to display the table in the terminal. So LaTeX textcolor commands are unlikely to work.

Using an R or Python tables package, which seems OTT.

Is there another solution? Thanks!

Link: PrettyTables announcement

6 posts - 3 participants