-1

Let's say that I have a dataframe :

       col1  col2  col3
0      8     7     5
1      6     2     17
2      3     1     21
3      4     3     9

I want to remove every rows where col3 value is bigger than 10 and smaller than 20 and get the result :

       col1  col2  col3
0      8     7     5
1      3     1     21
2      4     3     9

How can i code this in python?

rid
  • 61,078
  • 31
  • 152
  • 193
Sharon S
  • 15
  • 1
  • 5

1 Answers1

-2

Just extract everything that doesn't match the above criteria:

df[~((df.col3 > 10) & (df.col3 < 20))]

Result:

   col1  col2  col3
0     8     7     5
2     3     1    21
3     4     3     9
Roy2012
  • 11,755
  • 2
  • 22
  • 35