Quick solution to a problem I had today. I had a dictionary of {key, values} that I wanted into a dataframe. My solution:
import pandas as pd
pd.DataFrame([[key,value] for key,value in python_dict.iteritems()],columns=["key_col","val_col"])
-->
why do you want to do that when it can be done directly as :
ReplyDeletel = [{k1:v11, k2:v21},
{k1:v21, k2:v22}, .....]
pd.DataFreame(l)
That only works if you already have a list. My usecase was when I only had a single dictionary full of keys and values. You have to make it a list first.
Delete