I've been able to filter Pandas dataframe rows containing a number:
import pandas as pd
df = pd.DataFrame({'c1': [3, 1, 2], 'c2': [3, 3, 3], 'c3': [2, 5, None], 'c4': [1, 2, 3]})
c1 c2 c3 c4
0 3 3 2.0 1
1 1 3 5.0 2
2 2 3 NaN 3
df1 = df[(df.values == 1)]
c1 c2 c3 c4
0 3 3 2.0 1
1 1 3 5.0 2
But if I try to filter based excluding a number, I get a really strange result with repeated rows:
df1 = df[(df.values != 1)]
c1 c2 c3 c4
0 3 3 2.0 1
0 3 3 2.0 1
0 3 3 2.0 1
1 1 3 5.0 2
1 1 3 5.0 2
1 1 3 5.0 2
2 2 3 NaN 3
2 2 3 NaN 3
2 2 3 NaN 3
2 2 3 NaN 3
Why is that? And how can I filter only the rows that don't contain the specified number?
Thanks in advance!