I'm trying to convert a nested dictionary to multiindex dataframe where dictionary keys are columns labels.
my_dict = {"season":"summer", "threshold":70, "analysis" : {"max_temp":50, "min_temp":20}}
I followed the code which is linked to this question Nested dictionary to multiindex dataframe where dictionary keys are column labels but I've got an error AttributeError: 'str' object has no attribute 'items'
The following code:
reform = {(outerKey, innerKey): values for outerKey, innerDict in my_dict.items() for innerKey, values in innerDict.items()}
Could anyone help me to solve this issue?
Thanks in advance