Avatar ·

How to remove lines according to different conditions?

📁 python, numpy, pandas

there is a data frame and I need to delete lines from it in which the value of the column a is more than 50. This operation is successfully performed by the code:

  Import  pandas  as  pd  import  numpy  as  nprondf = PD.Dataframe ([ 256 ,  4 ,  24 ,  51 ], [ 24 ,,  25 ,  34 ,  200 ], [ 300 ,  12 ,  45 ,  11 ],  [ 34 ,  19 ,  2 ,  34 ], [ 75 ,  76 ,  19 ,  11 ], [ 42 ,  89 ,  29 ,  101 ], [ 54 ,  104 ,  11 ,  12 ]]) df.reneame ({ 0 :  'a' a 'a' a `` ",  1 :  'b' ,  2 :  'c' ,  3 :  'd' d '}, Axis =  1 , inplace =  true ) df_without_noise = df.drop (df [ 'a' ] & gt;  250 ) [ 0 ])  

and it tus out DATA-HIGHLIGHTED = ""> A B C D 1 24 25 34 200 3 34 19 2 34 4 75 76 19 11 5 42 89 29 101 6 54 104 11 12

Then you need to remove the lines in which the column in is more than 50. I repeat the operation similar to the first removal of the lines:

  df_without_noise = df_without_noise.drop (np.where (df_without_noise [] & gt;  50 ) [ 0 ])     

but displays the error:

keyeroror: '[2] not found in Axis'

In this case, the column in contains values ​​of more than 50.

how to remove lines with them? DATA-HIGHLIGHTED = ""> A B C D 1 24 25 34 200 3 34 19 2 34