Calculate distance based on a lookup dataframe
问题 I have a DataFrame and a lookup table. For a key in the DataFrame I would like to lookup the corresponding row in the lookup table and calculate the Euclidian distance for a number of columns. Mock data looks like import pandas as pd import numpy.random as rand df = pd.DataFrame({'key':rand.randint(0, 5, 10), 'X': rand.randn(10), 'Y': rand.randn(10), 'Z': rand.randn(10)}) X Y Z key 0 0.163142 0.387871 -0.433157 3 1 -2.020957 -1.537615 -1.996704 0 2 1.249118 1.633246 0.028222 1 3 -0.019601 1