展开全部
import itertools as it,pandas as pd
txt='''-2.50873-4.4332-0.35205
-1.38969-5.18877-0.27308
-0.11028-4.56514-0.25273
-0.00122-3.21829-0.32876
-1.1643-2.38933-0.43087
-2.42733-3.00607-0.42163
-3.6058-2.19928-0.47079
-3.54854-0.84289-0.4884
-2.24876-0.21977-0.47352
-1.09262-0.95155-0.49488
0.225891-0.21499-0.52048
1.184216-0.40293-1.57996
2.3943140.310171-1.53629
2.6437421.20664-0.45223
1.7291591.4212570.527241'''
txt=[list(map(float,x.split('\t'))) for x in txt.split('\n')]
data=list(it.combinations(txt,2))
def distance(p1,p2):
return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2 + (p1[2] - p2[2]) ** 2) ** 0.5
df=pd.DataFrame(data,columns=['点1','点2'])
df['距离e5a48de588b63231313335323631343130323136353331333433656134']=df.apply(lambda x:distance(*x),axis=1)
print(df)