title: Pandas Filtering one dataframe if a value is between two values from another data frame
body: <p>I have two data frames as follows:</p>
  <p>df1</p>
  <pre><code>  chr_number      start        end strand
  0       chr1  111478338  111478339      +
  1       chr1  111478370  111478371      +
  2       chr1  111478372  111478373      +
  3       chr1  157123306  157123307      -
  4       chr1  157123307  157123308      -
  5       chr1  212619741  212619742      +
  6       chr1  212619742  212619743      +
  </code></pre>
  <p>df2</p>
  <pre><code>  Chromosome      Start        End  Log2 Fold Change Strand      Gene  \
  0       chr1  111478330  111478444          3.036912      +  C1orf162   
  1       chr1  157123300  157123338          3.293174      -      ETV3   
  2       chr1  207079296  207079412          3.916122      +    PFKFB2   
  3       chr1  212619736  212619771          3.880546      +      ATF3   
  
             Ensembl ID Feature  
  0  ENSG00000143110.11  3' UTR  
  1  ENSG00000117036.12  3' UTR  
  2  ENSG00000123836.15  3' UTR  
  3  ENSG00000162772.17  3' UTR    
  </code></pre>
  <p>I need to look if start from df1 is located between Start and End in df2. If so, I'd like to have a new data frame which contains start value from df1 with corresponding row in df2.</p>
  <p>Here is the example of what I need for each start value from df1:</p>
  <pre><code>   CrossLink Chromosome        Start          End  Log2 Fold Change Strand  \
  1  111478338       chr1  111478330.0  111478444.0          3.036912      +   
  
         Gene          Ensembl ID Feature  
  1  C1orf162  ENSG00000143110.11  3' UTR 
  </code></pre>
  <p>I wrote this code:</p>
  <pre><code>df3 = pd.DataFrame([])
  df3[&quot;CrossLink&quot;] = np.nan
  for v in df1[&quot;start&quot;]:
      df4 = df2[(df2[&quot;Start&quot;] &lt;= v) &amp; (df2[&quot;End&quot;] &gt; v)]
      df3 = df3.append(df4)
      df3[&quot;CrossLink&quot;] = df1[&quot;start&quot;]
  </code></pre>
  <p>And I get this output:</p>
  <pre><code>   CrossLink Chromosome        Start          End  Log2 Fold Change Strand  \
  0  111478338       chr1  111478330.0  111478444.0          3.036912      +   
  0  111478338       chr1  111478330.0  111478444.0          3.036912      +   
  0  111478338       chr1  111478330.0  111478444.0          3.036912      +   
  1  111478370       chr1  157123300.0  157123338.0          3.293174      -   
  1  111478370       chr1  157123300.0  157123338.0          3.293174      -   
  3  157123306       chr1  212619736.0  212619771.0          3.880546      +   
  3  157123306       chr1  212619736.0  212619771.0          3.880546      +   
  
         Gene          Ensembl ID Feature  
  0  C1orf162  ENSG00000143110.11  3' UTR  
  0  C1orf162  ENSG00000143110.11  3' UTR  
  0  C1orf162  ENSG00000143110.11  3' UTR  
  1      ETV3  ENSG00000117036.12  3' UTR  
  1      ETV3  ENSG00000117036.12  3' UTR  
  3      ATF3  ENSG00000162772.17  3' UTR  
  3      ATF3  ENSG00000162772.17  3' UTR  
  </code></pre>
  <p>It does not contain all my start values from df1 and it gives me duplicates. I am quite new in python and pandas and I searched a lot but I couldn't figure it out.</p>
  <p>Thanks a lot in advance for your help!</p>