title: Searching for a range efficiently on a sorted Pandas dataframe
body: <p>I want to search values within a range in a sorted column of Pandas dataframe, in other words, a sorted Series. There are millions of rows so performance matters and I want to use binary search to reduce the complexity.</p>
  
  <p>The first problem is with <code>Pandas.Series.searchsorted(value)</code>, I cannot tell if the value actually exists in the series.
  e.g.:</p>
  
  <pre><code>&gt;&gt;x = pds.Series([1,2,3])
  &gt;&gt;x.searchsorted(1) -&gt; return 0
  &gt;&gt;x.searchsorted(-1) -&gt; return 0
  </code></pre>
  
  <p>How can I tell if the value actually exists in the series with this function?</p>
  
  <p>The second problem is searching for a range. I'd prefer something like <code>Pandas.Series.searchsorted(range)</code> to return the first index of the value within the range.</p>
  
  <p>Is there any packages can help? I am considering writing my own binary search functions but I do not want to ruin the performance advantage of Pandas/numpy. Is diving into Cython my only choice?</p>