I am trying to calculate the distance from each point (coordinate) of a column in a Dataframe to each point (coordinate) of another column in another Dataframe and save the minimum distance to a Dataframe, such that the resulting Dataframe has the same length as the first column. data: intern:
| ID | coordinates | 
|---|---|
| 1 | (50.939266, 6.934996) | 
| 2 | (50.935998, 6.931481) | 
360 entries
stops:
| Name | coordinates | 
|---|---|
| A | (50.93576, 6.96046) | 
| B | (50.9357, 6.95957) | 
2082 entries
desired result:
| ID | coordinates | min_distance | 
|---|---|---|
| 1 | (50.939266, 6.934996) | 1.8263939732112 | 
| 2 | (50.935998, 6.931481) | 0.3 | 
intern: 3 columns with 360 entries each, where the last column is the minimum distance of the coordinate in the second column to each coordinate of the stops Dataframe
I have tried:
intern_index = 0
stops_index = 0
min_distance = 99999
hs.haversine((50.939266, 6.934996), (50.93576, 6.96046), unit=Unit.KILOMETERS)
Out: 1.8263939732112031
for i in intern['coordinates']:
     
    
    for j in stops['coordinates']:
         
        new_distance = hs.haversine(i, j, unit=Unit.KILOMETERS)
        
        if new_distance < new_distance:
            min_distance = new_distance
             
            
    intern['min_distance'] = min_distance 
this yields:
| ID | coordinates | min_distance | 
|---|---|---|
| 1 | (50.939266, 6.934996) | 22.941973 | 
| 2 | (50.935998, 6.931481) | 22.941973 | 
why doesn't it save the correct value? even the first try was smaller than this value and it cannot all be the same distance either