Currently, I get have a dictionary with scalar values and a nested dictionary.
d = {'A': 'a', 'B': 'b', 'C':{0:'z', 1:'y'}}
I would like to put this into a pandas dataframe. However,
pd.DataFrame(d, index=[0])
Gives me only the first value of the nested dictionary. That is, .
Any idea how I can get instead?
Is there an elegant solution available? I'm hoping to avoid writing any loops.
CodePudding user response:
Put dict to list like:
df = pd.DataFrame([d])
print(df)
A B C
0 a b {0: 'z', 1: 'y'}