我有两个列表。每个列表有三行。每个列表的坐标系从上到下为(x,y,z)。我尝试使用数组,但是没有用。这是我的代码。
import numpy as np
p1 = np.array([list(marker_11_x['11:-.X']), list(marker_11_y['11:-.Y']),
list(marker_11_z['11:-.Z']) ])
p2 = np.array([list(original_x['13:-.X']), list(original_y['13:-.Y']),
list(original_z['13:-.Z'])])
squared_dist = np.sum(((p1[0]-p2[0])**2+(p1[1]-p2[1] )**2+(p1[3]-p2[3] )**2),
axis=0)
dist = np.sqrt(squared_dist)
list A = [-232.34, -233.1, -232.44, -233.02, -232.47, -232.17, -232.6, -232.29, -231.65]
[-48.48, -49.48, -50.81, -51.42, -51.95, -52.25, -52.83, -53.63, -53.24]
[-260.77, -253.6, -250.25, -248.88, -248.06, -247.59, -245.82, -243.98, -243.76]
List B = [-302.07, -302.13, -303.13, -302.69, -303.03, -302.55, -302.6, -302.46, -302.59]
[-1.73, -3.37, -4.92, -4.85, -5.61, -5.2, -5.91, -6.41, -7.4]
[-280.1, -273.02, -269.74, -268.32, -267.45, -267.22, -266.01, -264.79, -264.96]
TypeError跟踪(最近一次通话) pandas._libs.index.IndexEngine.get_loc()中的pandas_libs \ index.pyx
pandas中的pandas_libs \ hashtable_class_helper.pxi._libs.hashtable.Int64HashTable.get_item()
TypeError:必须为整数
在处理上述异常期间,发生了另一个异常:
KeyError跟踪(最近一次通话最近) 在()中 1将numpy导入为np 2 p1 = np.array([list(marker_11_x ['11:-。X']),list(marker_11_y ['11:-。Y']),list(marker_11_z ['11:-。Z'])] ) ----> 3 p2 = np.array([list(original_x ['13:-。X']),list(original_y ['13:-。Y']),list(original_z ['13:-。 Z'])]) 4 5 squared_dist = np.sum((((p1 [0] -p2 [0])** 2+(p1 [1] -p2 [1])** 2+(p1 [3] -p2 [3])* * 2),轴= 0)
getitem 中的E:\ ProgramData \ Anaconda3 \ lib \ site-packages \ pandas \ core \ series.py(自身,密钥) 764键= com._apply_if_callable(键,自) 765尝试: -> 766结果= self.index.get_value(self,key) 767 768,如果不是is_scalar(result):
get_value(self,series,key)中的E:\ ProgramData \ Anaconda3 \ lib \ site-packages \ pandas \ core \ indexes \ base.py 3101试试: 3102返回self._engine.get_value(s,k, -> 3103 tz = getattr(series.dtype,'tz',无) 3104,除了KeyError作为e1: 3105如果len(self)> 0,并且self.inferred_type为['integer','boolean']:
pandas._libs.index.IndexEngine.get_value()中的pandas_libs \ index.pyx
pandas._libs.index.IndexEngine.get_value()中的pandas_libs \ index.pyx
pandas._libs.index.IndexEngine.get_loc()中的pandas_libs \ index.pyx
KeyError:'13:-。X'
答案 0 :(得分:0)
代码以及公式将如下所示:
one = [x1,y1,z1] # first coordinates
two = [x2,y2,z2] # second coordinates
def distance_finder(one,two) :
return (((x2-x1)**2)+((y2-y1)**2)+((z2-z1)**2))**(1/2)