Reputation: 41
email_ad Name Manager_Name Manager_Band_level
[email protected]. Tom Banks Boss1 30
[email protected]. Bill Bob Boss2 40
How do I create a dictionary with email_ad as the key and each of the other columns in my data frame as values. I tried this
mydict={df['email_ad']:[df['Name'],df['Manager Name'], df['Manager_Band_level']]}
This did not work. I have been stuck forever on this. Any help would be amazing!
Upvotes: 0
Views: 41
Reputation: 13255
Use zip
with dict
as:
mydict = dict(zip(df['email_ad'], df.iloc[:, 1:].to_numpy().tolist()))
mydict
{'[email protected].': ['Tom Banks', 'Boss1', 30],
'[email protected].': ['Bill Bob', 'Boss2', 40]}
Upvotes: 1