I have a pandas dataframe with columns "X" and "Y". I want to obtain for each row the single maximum distance from all other rows. I know I can do this with nested loops such as:
for i_df,row in df.iterrows():
max_dist=0
for i_others,other_row in df.iterrows():
xdiff = row.X - other_row.X
ydiff = row.Y - other_row.Y
dist = np.sqrt(xdiff**2 + ydiff**2)
if dist>max_dist:
max_dist=dist
df.loc['max_dist'][i_df]=max_dist
Is there a computationally faster or more pythonic way to do this?