Hi, I want to compared all ‘value’ columns with their corresponding ‘benchmark_value’, and then colour all columns by ‘% changed value’ with colour scale according to value high to small like this.
I know how to highlight the cell based on absolute values by using the following code.
But can someone shed light on my question ? Thanks
import dash
import dash_table
import pandas as pd
import dash_html_components as html
import colorlover
from jupyter_dash import JupyterDash
df = pd.DataFrame(list(zip(
[99,98, 50],
[20, 11, 50],
[2, 1.9, 3],
[100,98, 100],
[10, 10, 20],
[1, 2, 3],
)), columns=[‘value1’, ‘value2’, ‘value3’, ‘benchmark_value1’,‘benchmark_value2’,‘benchmark_value3’])
app = JupyterDash(name)
cols = [‘value1’, ‘value2’, ‘value3’,]
(styles, legend) = discrete_background_color_bins(df, columns = cols)
app.layout = html.Div([
legend,
dash_table.DataTable(
id = ‘table’,
columns = [{“name”: i, “id”: i} for i in df.columns],
data = df.to_dict(‘records’),
style_data_conditional = styles
)
])
app.run_server(mode=‘inline’)