daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. from pandas import DataFrame
  3.  
  4. inp1 = [{'a':1, 'b':2, 'c':0}, {'a':1,'b':3,'c':0}, {'a':0,'b':3,'c':0}]
  5. df1 = DataFrame(inp1)
  6.  
  7. inp2 = [{'d':2, 'e':0}, {'d':0,'e':3}, {'d':0,'e':4}]
  8. df2 = DataFrame(inp2)
  9.  
  10. threshold = 1
  11.  
  12. df1.loc[np.sqrt((df1.a - df2.d) ** 2 + (df1.b - df2.e) ** 2) >   threshold, 'c'] = "yes"
  13.  
  14. print(df1)
  15. print(df2)
  16.  
  17.    a  b    c
  18. 0  1  2  yes
  19. 1  1  3    0
  20. 2  0  3    0
  21.  
  22.    d  e
  23. 0  2  0
  24. 1  0  3
  25. 2  0  4
RAW Paste Data
Top