I’ve encountered a difference between how my code runs locally vs. when it’s deployed on Streamlit.
Normally in Python/pandas, a dictionary can be stored in a dataframe cell like this
dict_name = {‘a’:1, ‘b’:2}
df.loc[index, column_name] = [dict_name]
The value for that specific index and column will then be the dictionary. See also the answer to this Stackoverflow question.
However in Streamlit, I’ve noticed that [dict_name] is interpreted and displayed as a dictionary within a list, so as [{‘a’:1, ‘b’:2}] instead of {‘a’:1, ‘b’:2}.
As a result, to grab the value associated with key ‘a’ in the dictionary in the df cell, locally I can run df.loc[index, column_name][‘a’], but in Streamlit, I need to run df.loc[index, column_name][0][‘a’] instead.
Is there anything on my side that I need to change, or is this an inconsistency on Streamlit side?