I have a dataframe with two columns, one is a string and the other is a number. I want my dash dropdown menu to have a ‘label’ field for each unique entry of the string column, and the ‘value’ field of the dropdown to be the column which contains the number on the same row. How would I do this?
I thought it might be something like this, but it doesn’t work, because it functions as a for loop of a for loop.
options=[ {'label': i, 'value': j} for i in court_code_df['court_name'].unique() for j in court_code_df['mis_data_source_code'].unique() ],
Example data:
court_name mis_data_source_code
aaa 562
bbb 435
So I can see the options of ‘aaa’, ‘bbb’ in the dropdown, but the value returned by ‘aaa’ would be 562, and for ‘bbb’ it would be 435, and so on for all the columns in the ‘court_code_df’ dataframe.