Stack Team! I have a data frame that I'd like to convert into a dictionary with one of the columns as the key and the values of another column appended to a list within the dictionary.
I've been able to convert the data frame into a dictionary with key value pairs for each row of the data frame, but I simply need a series or list appended to a series belonging to each dictionary key.
DataFrame:
Team Name ID
0 Idaho 1234
1 Idaho 5678
2 Tokyo 5432
Tried this and I get a dictionary containing dictionaries. The ID are set to keys with the row records from the data frame as values.
Code Attempt:
team_id_df.set_index('Team Name').to_dict(orient='index')
Result:
{'Idaho': {'ID': 1234, 'ID': 5678}, 'Tokyo': { 'ID': 5432}}
But I'm trying to get this:
{'Idaho': [1234, 5678],'Tokyo': [5432]}
I'm a little stumped, any suggestions for making this transformation?