Create Linestring For Unique Values In Pandas Dataframe
I have a pandas dataframe I would like to iterate over. For instance a simplified version of my dataframe can be: abc begin end ID Lat Long def1 001 123 C
Solution 1:
I don't have the LINESTRING package installed, but I guess you can easily convert what's in d into the format you need.
d = {}
df.groupby('ID').apply(lambda x: d.update({x.ID.iloc[0]:x[['Lat','Long']].values.tolist()}))
{'CAT': [[13.167, 52.411], [13.22, 52.064], [13.304, 52.121]],
'DOG': [[13.685, 52.532], [12.02, 52.277]],
'MOOSE': [[13.698, 52.131], [13.699, 52.549], [11.011, 52.723]]}
Post a Comment for "Create Linestring For Unique Values In Pandas Dataframe"