I have the following Pandas DataFrame:
x1 y1 z1 s1 x2 y2 z2 s2 x3 y3 z3 s3 x4 y4 z4 s4 xto yto zto
1 1 1 1 1 4 5 7 11 17 89 34 1 1 1 1 1 1 1
4 4 4 1 4 5 7 10 17 79 34 31 51 51 19 10 61 21 20
4 4 4 1 4 5 7 10 17 79 34 31 51 51 19 10 61 21 20
4 4 4 1 4 5 7 10 17 79 34 31 51 51 19 10 61 21 20
I need please the euclidean distance also:
d1 = sqr(x1-xto)^2+(y1-yt0)^2+(z1-zto)^2
d2 = sqr(x2-xto)^2+(y2-yt0)^2+(z2-zto)^2
d3 = sqr(x3-xto)^2+(y3-yt0)^2+(z3-zto)^2
d4 = sqr(x4-xto)^2+(y4-yt0)^2+(z4-zto)^2
to get a new dataframe. something like this:
d1 s1 d2 s2 d3 s3 d4 s4
02 31 41 52 63 54 55 85
02 71 81 52 63 54 55 85
02 51 41 52 63 54 55 85
02 31 41 52 63 54 55 85
Try the SciPy Library , there is a method for calculating the Euclidean distance. The argument for the method is array like so you should be able to feed in columns from a pd.df
You can then make list of distances and put them in a dataframe
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.