Trying to understand what the best idea/practice here would be.. I have a dataframe with interviewers at various locations.. I would like to create a dictionary or some sort of data structure that holds the interviewers name and then every coordinate point we have for their interview. An example of the dataframe I am working with is something like this:
interview longitude latitude
1 A1 34.2 90.2
2 A1 54.2 23.5
6 A1 NaN NaN
7 A2 NaN NaN
8 A2 NaN NaN
9 A2 23.1 38.2
10 A2 -23.7 -98.4
I would like to essentially have a dictionary that has 'A1' and it holds (34.2, 90.2), (54.2, 23.5) and 'A2' would hold (23.1, 39.2), (-23.7, -98.4).
location_dict = {}
for name, group in df.groupby('Interviewer'):
minidf = group[['Interviewer','Longitude','Latitude']].dropna()
for index, row in minidf.iterrows():
location_dict[name]=(row['Longitude'], row['Latitude'])
My logic here is a bit off, but I don't have any way to 'append' to a dictionary, so my dictionary is only outputting the data from last iteration of iterrows... How would I go about fixing this?