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

PHOTO EMBED

Thu Aug 27 2020 19:54:14 GMT+0000 (Coordinated Universal Time)

Saved 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_copyCOPY

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