So I have a csv file which consists of 3 columns (City,Latitude,Longitude) and I have created a data frame in python from this csv file using this code
data = pd.read_csv("lat_long.csv",nrows=10)
Lat = data.lat.tolist()
Lon = data.lon.tolist()
suburb = data.suburb.tolist()
dict={'Latitude':Lat,'Longitude':Lon}
df = pd.DataFrame(dict,index=(suburb))
And the output is this
Latitude Longitude
AUSTRALIAN NATIONAL UNIVERSITY -35.277272 149.117136
BARTON -35.201372 149.095065
DARWIN -12.801028 130.955789
DARWIN -12.801028 130.955789
PARAP -12.432181 130.843310
ALAWA -12.378451 130.877014
BRINKIN -12.367769 130.869808
CASUARINA -12.376597 130.850489
JINGILI -12.385761 130.873726
LEE POINT -12.360865 130.891349
Now what I want is all possible combination of distance from 1 city to other 9 cities. It should look like
DISTANCE
AUSTRALIAN NATIONAL UNIVERSITY- BARTON
AUSTRALIAN NATIONAL UNIVERSITY - DARWIN
AUSTRALIAN NATIONAL UNIVERSITY - DARWIN
AUSTRALIAN NATIONAL UNIVERSITY - PARAP
I have tried doing this using nested for loops and it works but I want a bit faster.