title: How to efficiently find overlapping intervals?
body: <p>I have the following toy example dataframe, <code>df</code>:</p>
  <pre><code>      f_low    f_high
     0.476201  0.481915
     0.479161  0.484977
     0.485997  0.491911
     0.503259  0.508679
     0.504687  0.510075
     0.504687  0.670075
     0.666093  0.670438
     0.765602  0.770028
     0.766884  0.771307
     0.775986  0.780398
     0.794590  0.798965
  </code></pre>
  <p>to find overlapping subsets of this, I am using the following code:</p>
  <pre><code>df = df.sort_values('f_low')
  for row in df.itertuples():
      iix = pd.IntervalIndex.from_arrays(df.f_low, df.f_high, closed='neither')
      span_range = pd.Interval(row.f_low, row.f_high)
      fx = df[(iix.overlaps(span_range))].copy()
  </code></pre>
  <p>I would LIKE to get overlapping dataframes like this:</p>
  <pre><code>   # iteration 1: over row.f_low=0.476201  row.f_high=0.481915 
  
        f_low    f_high
     0.476201  0.481915
     0.479161  0.484977
  
     # iteration 2: over row.f_low=0.503259  row.f_high=0.508679 
        f_low    f_high
     0.503259  0.508679 
     0.504687  0.510075
     0.504687 0.670075
  
     # iteration 3: over row.f_low=0.504687  row.f_high=0.670075 
        f_low    f_high
     0.666093  0.670438
  </code></pre>
  <p>etc.</p>
  <p>This works great, but since the dataframe is quite large and there are a lot of overlaps, this takes a long time to process. Also, the interval I am testing for overlaps does not grab itself when using the <code>Interval</code> and <code>overlaps</code> methods for pandas.</p>
  <p>What this is meant to represent is a series of overlapping confidence intervals with each row that gets iterated over.</p>
  <p>Is there a way to more efficiently extract overlapping intervals against a given interval besides iterating through all the tuples?</p>
  <p>Here is a chunk of the actual dataframe unsorted:</p>
  <pre><code>f_low   f_high
  0.504687  0.670075
  0.476201  0.481915
  0.765602  0.770028
  0.479161  0.484977
  0.766884  0.771307
  0.485997  0.491911
  0.666093  0.670438
  0.503259  0.508679
  0.775986  0.780398
  0.504687  0.510075
  0.794590  0.798965
  </code></pre>