title: Check if dataframe value +/- 1 exists anywhere else in a given column
body: <p>Let's say I have a dataframe df that looks like this:</p>
  
  <pre><code>   irrelevant   location
  0           1          0
  1           2          0
  2           3          1
  3           4          3     
  </code></pre>
  
  <p>How do I create a new true/false column "neighbor" to indicate if the value in "location" +/- 1 (plus or minus 1) exists anywhere else in the "location" column. Such that:</p>
  
  <pre><code>   irrelevant   location   neighbor
  0           1          0       True
  1           2          0       True
  2           3          1       True
  3           4          3       False
  </code></pre>
  
  <p>The last row would be false, because neither 2 nor 4 appear anywhere in the df.location column. </p>
  
  <p>I've tried these:</p>
  
  <pre><code>&gt;&gt;&gt; df['neighbor']=np.where((df.location+1 in df.location.unique())|(df.location-1 in df.x.unique()), True, False)
  
  ValueError: Lengths must match to compare
  
  </code></pre>
  
  <pre><code>&gt;&gt;&gt; df['tmp']=np.where((df.x+1 in df.x.tolist())|(df.x-1 in df.x.tolist()), 'true', 'false')
  
  ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
  
  </code></pre>
  
  <p>Alternatively, thanks in advance for help directing me to earlier instances of this question being asked (I don't seem to have the right vocabulary to find them).</p>