I am pretty sure that ~
in Pandas is boolean not
. I found a couple of StackOverflow questions / answers, but no pointer to official documentation.
Sanity Check
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
df = pd.DataFrame([(1, 2, 1),
(1, 2, 2),
(1, 2, 3),
(4, 1, 612),
(4, 1, 612),
(4, 1, 1),
(3, 2, 1),
],
columns=['groupid', 'a', 'b'],
index=['India', 'France', 'England', 'Germany', 'UK', 'USA',
'Indonesia'])
print(df)
filtered = df[~(df['a'] == 2)]
print(filtered)
The df is
groupid a b
India 1 2 1
France 1 2 2
England 1 2 3
Germany 4 1 612
UK 4 1 612
USA 4 1 1
Indonesia 3 2 1
and filtered
is
groupid a b
Germany 4 1 612
UK 4 1 612
USA 4 1 1
So I'm pretty sure it is boolean not.