I’m trying to run a function based on an input of a dropdown.
[Input('field-dropdown', 'value')] , , [Event('submit-button', 'click')])
df = run_function(user_selection)
The function produces a dataframe, which I want the app to portray. The function works perfectly when I run it alone, but in the app, no table is produced giving me an error ‘Key must be string’.
What does this mean and how can I resolve it?
field-dropdown is providing a number instead of a string, because of its setup-code.
If that is the case, you could either use
str(user_selection) or change the
value's in the options
(and the default/selected value) to strings.
Thanks for the input, but that’s not the issue. I tried the `str(user_selection)… and I dont get an error when the same process calls a dataframe, it just occurs when i call a function that produces a dataframe.
I’ll let you know if i find a way around it!
I found something quiet odd. So I googled the error, its a bug and someone suggested the following work around,
[Input(‘field-dropdown’, ‘value’)] , , [Event(‘submit-button’, ‘click’)])
df = run_Bid(user_selection)
for key in df.keys():
if type(key) is not str:
df[str(key)] = df[key]
df[repr(key)] = df[key]
But then, the columns with ‘string’ indexes are all deleted! I have no idea whats happening haha
Soo… the error is caused because some of the column indexes were strings and the others were numbers. Once I renamed them all to be strings or integers, the problem was solved.