How to update slider value by FileInput

I created an interactive Bokeh dashboard with several sliders. The configuration of all the sliders represent one scenario, which can be exported to a CSV file. Now I would like to be able to reload the scenario, which is stored in a CSV to update the values of the sliders. Unfortunately I am getting the following error:

ValueError: failed to validate Slider(id='3566', ...).value: expected a value of type Real, got [16.] of type ndarray

I dont understand what is meant with “type Real” and how to adjust it.

The FileInput lines look as follows:

def import_data(attr, old, new):

            decoded = b64decode(new)
            f = io.BytesIO(decoded)
            
            df=pd.read_csv(f, sep=';', engine='python')
            dff = pd.DataFrame(df)
            
            source=ColumnDataSource(data=dff)          
            slider.value=source.data['Column1'] #the column has only 1 row with the value 16
            slider2.value=source.data['Column2']
            slider3.value=source.data['Column3']

            
 file_input.on_change('value', import_data)

I have basically tried the same thing without ColumnDataSoure, but it resulted in the same error.

(python - How to update slider value by FileInput Bokeh - Stack Overflow)

It looks like what you’re giving the slider.value is the array with 16 in it, and not just the value 16. What happens if you add an index to that row? Like this:

slider.value=source.data['Column1'][0]
2 Likes

@ZetDen please also self-answer (or delete) the SO question to help keep the [bokeh] tag on SO tidy.