Hi,
I am trying to write a code to highlight the cells that have a different value in comparison to the preceding row in dash or ag-grid table.
Inside a large callback I tried the following without success:
styles = []
for i in range(1, len(df)):
prev_row = df.iloc[i-1]
curr_row = df.iloc[i]
# Compare values in each column
for col in df.columns:
if curr_row[col] != prev_row[col]:
styles.append({
'if': {
'filter_query': f'index = {i} and column_id = "{col}"',
},
'backgroundColor': '#FF4136',
'color': 'white'
})
method_table = dash_table.DataTable(
data=df.to_dict("records"),
columns=[{"name": i, "id": i} for i in df.columns],
style_data_conditional=styles,
style_header={'backgroundColor': 'rgb(44, 62, 80)', 'color': 'white'}
)
Any suggestions would be appreciated.