Average distance within group in pandas
I have a dataframe like this df = pd.DataFrame({ ‘id’: [‘A’,’A’,’B’,’B’,’B’], ‘x’: [1,1,2,2,3], ‘y’: [1,2,2,3,3] }) The output I want is the average distance for each point in the group, in this example group A: (distance((1,1),(1,2))) /1 = 1 group B: (distance((2,2),(2,3)) + distance((2,3),(3,3)) + distance((2,2),(3,3))) /3 = 1.138 I can calculate the distance using… Read More Average distance within group in pandas