0 points

create a dictionary of two pandas Dataframe columns? - Stack Overflow


dashboard

Thu Aug 27 2020 19:54:14 GMT+0000 (UTC)

Posted by @arielvol #python

df.set_index(KEY).to_dict()[VALUE]

3 ways:
dict(zip(df.A,df.B))
pd.Series(df.A.values,index=df.B).to_dict()
df.set_index('A').to_dict()['B']
content_copy Copy

https://stackoverflow.com/questions/17426292/what-is-the-most-efficient-way-to-create-a-dictionary-of-two-pandas-dataframe-co