Hi I am trying to create sliders for adjusting the values of a model using a dictionary.
The dataframe contains multiple columns of floats.
The index column are unique city names that are used to select a slice of the data.
The column names and index are object type.
def display_sliders():
sliders = {}
for col in dti_consolidated_all.columns:
min_val = dti_consolidated_all[col].min()
max_val = dti_consolidated_all[col].max()
val = dti_consolidated_all[col].loc[selected_city]
sliders[col] = st.slider(col, min_value=min_val, max_value=max_val, value=val)
return sliders
# Display the slider widgets
sliders = display_sliders()
When I run the code it returns an error:
KeyError: <class 'numpy.float64'>
The error points to the line:
sliders[col] = st.slider(col, min_value=min_val, max_value=max_val, value=val)