So I have a df that I can display using data_table without any issues. I also compare between two columns of the df, and background color cells red of rows that are different. However, my issue is, how do I only display rows that are different just using the dashtable filtering? This is what I have so far in terms of displaying entire df using dashtable and only highlighting different rows based on Device1 and Device2 values.
comptable = html.Div([html.H5(" "),
dash_table.DataTable(id='xmlreadtable',
data=comp_df.to_dict('rows'),
columns=[{'name': i, 'id': i} for i in comp_df.columns],
style_header={'backgroundColor': 'rgb(230, 230, 230)','fontWeight': 'bold'},
page_action='none',
export_format='csv',
style_table={'height': '770px', 'overflowX': 'scroll'},
style_cell={'textAlign':'left','minWidth': 40, 'maxWidth': 90, 'width': 90,'font_size': '16px','whiteSpace':'normal','height':'auto'},
style_data_conditional=[{
'if': {'column_id': 'Device1',
'filter_query': '{Device1} != {Device2}'},
'backgroundColor': '#FF0000',
'color': 'white',
},
{
'if': {'column_id': 'Device2',
'filter_query': '{Device1} != {Device2}'},
'backgroundColor': '#FF0000',
'color': 'white',
},
]
)
])
I can create a new df which is a subset of the original df:
sub_df = df[(df['Device1'] != df['Device2'])]
But I would rather filter already displayed table. Also, will export_csv export only rows that are different or the entire df.