0

How do i write the python code to drop certain values? E.g. I want to drop an extreme value in the data frame column. I tried to select first before dropping which failed.

data[['Metabolic rate']>2000] also tried; data['Metabolic rate'>2000]

TypeError Traceback (most recent call last) in 1 #your answer ----> 2 data[['Metabolic rate']>2000]

TypeError: '>' not supported between instances of 'list' and 'int'

1 Answers1

0

Assuming data is the name of the dataframe:

data.drop(data[data['Metabolic rate'] > 2000].index, inplace=True)
Matt
  • 380
  • 1
  • 9
  • Thanks. I actually used a working code for dummies (i am still learning) as below; data['Metabolic rate'>2000] #\n #\n data[data['Metabolic rate']>2000] #\n data #index for >2000 ==39 #\n data_Metab=data.drop(39) – Hemal Patel Mar 18 '20 at 20:16