filter a pandas data frame on all rows that do NOT meet a condition
<p>This seems simple, but I can't seem to figure it out. I know how to filter a pandas data frame to all rows that meet a condition, but when I want the opposite, I keep getting weird errors.</p>

<p>Here is the example. (Context: a simple board game where pieces are on a grid and we're trying to give it a coordinate and return all adjacent pieces, but NOT the actual piece on that actual coordinate)</p>

<pre><code>import pandas as pd
import numpy as np

df = pd.DataFrame([[5,7, 'wolf'],
              [5,6,'cow'],
              [8, 2, 'rabbit'],
              [5, 3, 'rabbit'],
              [3, 2, 'cow'],
              [7, 5, 'rabbit']],
              columns = ['lat', 'long', 'type'])

coords = [5,7] #the coordinate I'm testing, a wolf

view = df[((coords[0] - 1) &lt;= df['lat']) &amp; (df['lat'] &lt;= (coords[0] + 1)) \
    &amp; ((coords[1] - 1) &lt;= df['long']) &amp; (df['long'] &lt;= (coords[1] + 1))]

view = view[not ((coords[0] == view['lat']) &amp; (coords[1] == view['long'])) ] 

print(view)
</code></pre>

<p>I thought the <code>not</code> should just negate the boolean inside the parentheses that followed, but this doesn't seem to be how it works. </p>

<p>I want it to return the cow at 5,6 but NOT the wolf at 5,7 (because that's the current piece). Just to double check my logic, I did </p>

<pre><code>me = view[(coords[0] == view['lat']) &amp; (coords[1] == view['long'])] 
print(me)
</code></pre>

<p>and this returned just the wolf, as I'd expected. So why can't I just put a <code>not</code> in front of that and get everything else? Or, more importantly, what do I do instead to get everything else.</p>