Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Slider filter for DataTable | Python

$
0
0

I have a dcc.slider that is filtering out datatable rows based off of the normalized value count, or frequency of occurrence, of the value in a specified column. That’s the intention at least. The filter is functioning but only on the first ‘hit’ of the if statement when return is under the if statement. When the return statement is outside of the for loop, nothing is filtered. Example provided below. Any advice is appreciated, I’m new to Dash.

@app.callback(
    Output("table", "data"),
    [Input('frequency_slider', 'value'),])

def filter_table(value):
    if value is None:
        return dash.no_update

    frequency = table['name'].value_counts(normalize=True)
    for index, cell_value_frequency in frequency.iteritems():
        if cell_value_frequency >= value:
            filtered_table = table[~table.name.str.contains(index)]
            
    return filtered_table.to_dict('records')

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images