用python计算23个11维数据的欧氏距离
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
data=pd.read_csv(r'E:\7 Python\data\20170713\quanguo.csv')
print data
import numpy as np
mydis_ed=[]
for i in range(0,23):
dis_ed = []
for j in range(0,23):
ed = np.sqrt(np.sum((data.ix[:,i] - data.ix[:,j]) ** 2))
dis_ed.append(ed)
mydis_ed.append(dis_ed)
print mydis_ed
mydis_ed = pd.DataFrame(mydis_ed)
mydis_ed.to_csv(r'E:\7 Python\data\20170713\quanguo-dis.csv', encoding='utf-8', index=False)