My dataframe is given below. i want to drop rows in two columns which have less than 0 value.
df =
name value1 value2
0 A 10 10
1 B -10 10 #drop
2 A 10 10
3 A 40 -10 #drop
4 C 50 10
5 C 60 10
6 D -70 -10 #drop
I want to drop rows with negative values in value1 and value2 columns. My expected output:
df =
name value1 value2
0 A 10 10
1 A 10 10
2 C 50 10
3 C 60 10
My present code:
df = df[df['value1','value2']>0]
Output:
KeyError: ('value1','value2')
df[df._get_numeric_data().gt(0).all(1)]?df[df[['value1', 'value2']].gt(0).all(1)]?gtis greater than,gegreater than equal todf[df[['value1', 'value2']].gt(0).all(1)]This worked. Thanks