title: Find closest point in Pandas DataFrames
body: <p>I am quite new to Python. I have the following table in Postgres. These are Polygon values with four coordinates with same <code>Id</code> with <code>ZONE</code> name I have stored this data in Python dataframe called <code>df1</code></p>
  
  <pre><code>Id  Order   Lat              Lon            Zone
  00001   1   50.6373473  3.075029928          A
  00001   2   50.63740441 3.075068636          A
  00001   3   50.63744285 3.074951754          A 
  00001   4   50.63737839 3.074913884          A 
  00002   1   50.6376054  3.0750528            B
  00002   2   50.6375896  3.0751209            B
  00002   3   50.6374239  3.0750246            B
  00002   4   50.6374404  3.0749554            B
  </code></pre>
  
  <p>I have Json data with <code>Lon</code> and <code>Lat</code> values and I have stored them is python dataframe called <code>df2</code>.</p>
  
  <pre><code>Lat                  Lon
  50.6375524099   3.07507914474
  50.6375714407   3.07508201591
  </code></pre>
  
  <p>My task is to compare <code>df2</code> <code>Lat</code> and <code>Lon</code> values with four coordinates of each zone in <code>df1</code> to extract the zone name and add it to <code>df2</code>.</p>
  
  <p>For instance <code>(50.637552409 3.07507914474)</code> belongs to <code>Zone B</code>.</p>
  
  <pre><code>#This is ID with Zone
  df1 = pd.read_sql_query("""SELECT * from "zmap" """,con=engine)
  #This is with lat,lon values
  df2 = pd.read_sql_query("""SELECT * from "E1" """,con=engine)
  df2['latlon'] = zip(df2.lat, df2.lon)
  zones = [
  ["A", [[50.637347297, 3.075029928], [50.637404408, 3.075068636], [50.637442847, 3.074951754],[50.637378390, 3.074913884]]]]
  for i in range(0, len(zones)):  # for each zone points
      X = mplPath.Path(np.array(zones[i][1]))
      # find if points are Zones
      Y= X.contains_points(df2.latlon.values.tolist())
      # Label points that are in the current zone
      df2[Y, 'zone'] = zones[i][0]
  </code></pre>
  
  <p>Currently I have done it manually for Zone 'A'. I need to generate the "Zones" for the coordinates in df2.</p>