I try to separate a Dataframe based on rows with a certain value in multiple columns, so that the original Dataframe is split in two with all rows containing the value in one Dataframe and the other Dataframe with the residual rows.
df = pd.DataFrame(np.random.randint(-1,100,size=(100, 4)), columns=list('ABCD'))
df
A B C D
0 51 86 15 80
1 61 53 75 66
2 80 48 23 58
3 86 25 37 99
4 50 11 87 71
... ... ... ... ...
95 34 40 43 40
96 89 16 83 72
97 97 32 24 26
98 27 83 75 29
99 24 50 40 43
100 rows × 4 columns
df[~df.isin([-1])].dropna()
A B C D
0 51 86 15 80.0
1 61 53 75 66.0
2 80 48 23 58.0
3 86 25 37 99.0
4 50 11 87 71.0
... ... ... ... ...
95 34 40 43 40.0
96 89 16 83 72.0
97 97 32 24 26.0
98 27 83 75 29.0
99 24 50 40 43.0
98 rows × 4 columns
df[df.isin([-1])].dropna()
A B C D
is what i tried so far and the first part worked correctly. However df[df.isin([-1])].dropna() failed.


