Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import filedialog
  3. import pandas as pd
  4. import, numpy as np
  5. from scipy.spatial.distance import pdist, squareform
  6.  
  7. root = tk.Tk()
  8. root.withdraw()
  9. file_path = filedialog.askopenfilename()
  10.  
  11. data = pd.read_excel(file_path)
  12. data = np.array(data, dtype=np.float)
  13. npoints, cols = data.shape
  14.  
  15. pwdistance = np.zeros((npoints, npoints))
  16. pwresidual = np.zeros((npoints, npoints))
  17. for i in range(npoints):
  18. for j in range(npoints):
  19. pwdistance[i][j] = np.sqrt((data[:,0][i]-data[:,0][j])**2 + (data[:,1][i]-data[:,1][j])**2)
  20. pwresidual[i][j] = (data[:,2][i]-data[:,2][j])**2
  21.  
  22. pwdistance = squareform(pdist(data[:,:2]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement