I have a dataframe which looks like this:
code to create the df:
dd = {'name': ["HARDIE'S MOBILE HOME PARK", 'CRESTVIEW RV PARK',
'HOMESTEAD TRAILER PARK', 'HOUSTON PARK MOBILE HOME PARK',
'HUDSON MOBILE HOME PARK', 'BEACH DRIVE MOBILE HOME PARK',
'EVANS TRAILER PARK'],
'country': ['USA', 'USA', 'USA', 'USA', 'USA', 'USA', 'USA'],
'coordinates': ['30.44126118, -86.6240656099999',
'30.7190163500001, -86.5716222299999',
'30.5115772500001, -86.4628417499999',
'30.4424195300001, -86.64733076',
'30.7629176200001, -86.5928893399999', '30.44417349, -86.59951996',
'30.4427800300001, -86.62941091'],
'status':['OPEN', 'CLOSED', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'OPEN']}
df2 = pd.DataFrame(data=dd)
What I want to do is to create a dictionary with the following structure:
{'destination1': 'CRESTVIEW RV PARK; 30.7190163500001, -86.5716222299999',
'destination2': 'HOMESTEAD TRAILER PARK; 30.5115772500001, -86.4628417499999',
'destination3': 'HOUSTON PARK MOBILE HOME PARK; 30.4424195300001, -86.64733076',
'destination4': 'HUDSON MOBILE HOME PARK; 30.7629176200001, -86.5928893399999',
'destination5': 'BEACH DRIVE MOBILE HOME PARK ; 30.44417349, -86.59951996'}
As you may see, each value must contain name;coordinates from second row to the last row. I am using the following code to do that:
d1 = {f"destination{k}":v + "; " + i for k in range(1, len(df1)-1) for v,i in zip(df1.name, df1.coordinates)}
However, this is the output I am getting:
{'destination1': 'EVANS TRAILER PARK; 30.4427800300001, -86.62941091',
'destination2': 'EVANS TRAILER PARK; 30.4427800300001, -86.62941091',
'destination3': 'EVANS TRAILER PARK; 30.4427800300001, -86.62941091',
'destination4': 'EVANS TRAILER PARK; 30.4427800300001, -86.62941091',
'destination5': 'EVANS TRAILER PARK; 30.4427800300001, -86.62941091'}
It is only reading the last line from the dataframe and each key has the same value but what I want is that for each key, its value must come from each row from the dataframe from the second row to the last row.
If anyone has any idea of how to do that I would really appreciate your help.