title: Finding intersection of Pandas dataframes within range
body: <p>A project I'm working on requires merging two dataframes together along some line with a delta. Basically, I need to take a dataframe with a non-linear 2D line and find the data points within the other that fall along that line, plus or minus a delta.</p>
  <h3>Dataframe 1 (Line that we want to find points along)</h3>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  
  df1 = pd.read_csv('path/to/df1/data.csv')
  df1
  </code></pre>
  <pre><code>         x        y
  0     0.23     0.54
  1     0.27     0.95
  2     0.78     1.59
  ...
  97    0.12     2.66
  98    1.74     0.43
  99    0.93     4.23
  </code></pre>
  <h3>Dataframe 2 (Dataframe we want to filter, leaving points within some delta)</h3>
  <pre class="lang-py prettyprint-override"><code>df2 = pd.read_csv('path/to/df2/data.csv')
  df2
  </code></pre>
  <pre><code>          x        y
  0      0.21     0.51
  1      0.27     0.35
  2      3.45     1.19
  ...
  971    0.94     2.60
  982    1.01     1.33
  993    0.43     2.43
  </code></pre>
  <h3>Finding the coarse line</h3>
  <pre><code>DELTA = 0.03
  
  coarse_line = find_coarse_line(df1, df2, DELTA)
  coarse_line
  </code></pre>
  <pre><code>          x        y
  0      0.21     0.51
  1      0.09     2.68
  2      0.23     0.49
  ...
  345    1.71     0.45
  346    0.96     0.40
  347    0.81     1.62
  </code></pre>
  <p>I've tried using <code>df.loc((df['x'] &gt;= BOTLEFT_X) &amp; (df['x'] &gt;= BOTLEFT_Y) &amp; (df['x'] &lt;= TOPRIGHT_X) &amp; (df['y'] &lt;= TOPRIGHT_Y))</code> among many, many other Pandas functions and whatnot but have yet to find anything that works, much less anything efficient (with datasets &gt;2 million points).</p>