I have a .csv file that contains city, latitude and longitude data in the below format:
CITY|LATITUDE|LONGITUDE
A|40.745392|-73.978364
B|42.562786|-114.460503
C|
for i in df["CITY"]:
for j in df["CITY"]:
row = df[df["CITY"] == j][["LATITUDE", "LONGITUDE"]]
latitude = row["LATITUDE"].tolist()[0]
longitude = row["LONGITUDE"].tolist()[0]
df.loc[df['CITY'] == i, j] = ((df["LATITUDE"] - latitude)**2 + (df["LONGITUDE"] - longitude)**2)**0.5
df = df.drop(["CITY", "LATITUDE", "LONGITUDE"], axis=1)
This works