Egor Ulybin
Egor Ulybin

Reputation: 57

Dictionary Comprehension with Pandas Data Frame, how to get all occurrences of a match?

name,age

ben,28

laura,29

tom,28

The above is the structure of my CSV file.

my_dict = {row.age: row for (index, row) in data.iterrows()} 

When I print(my_dict) I only see Tom and not Ben, why is one getting overwritten by the next and how can I re-write my code to see all of the data reflected in this particular key:value format?

Upvotes: 0

Views: 29

Answers (0)

Related Questions