I have the following df and dictionary:
df = pd.DataFrame({'Name1': [1,2,3],
'Name2': [1,2,3]})
dict = {'Weight':['kg','tons','lbs'],
'Speed':['m/s', 'km/hr']}
I would like to create 3 dropdowns using st.selectbox
In the first dropdown, I select names (returns: Name1, Name2
)
In the second dropdown, I select dict.keys (returns: 'Weight','Speed'
)
Here is my challenge: In the third dropdown I need to return the values of the key of the second dropdown prop
. For instance, if on prop
dropdown I choose Speed
, then my 3rd dropdown needs to contain 'm/s', 'km/hr'
, similarly if prop
dropdown is selected as Weight
, then my 3rd dropdown must contain 'kg','tons','lbs'
See my attempt below. The last line unit
which I am struggling with is returning an error
TypeError: 'builtin_function_or_method' object is not iterable
col1, col2, col3 = st.columns([2,1,1])
with col1:
name = st.selectbox('Choose name', options=(v for v in df.columns), key=1)
with col2:
prop = st.selectbox('Choose Property', options=(v for v in dict.keys()), key=2)
with col3:
unit = st.selectbox('Choose Unit', options=(v for v in dict.values if dict.keys == weight), key=3)