Skip to content
Advertisement

Remove outlier using quantile python

I need to remove outlier for a regression dataset. Lets say the dataset is consist in the following way

JavaScript

With closer inspection, the column humidity has three outliers which are 50.0,18.0,0.01 but for windspeed column the outliers are 20 and 0.05 and both columns outliers are not in the same row. In this case if I remove my outlier with the code above, I would get the following error:

JavaScript

From what I understand, the length of row in each column is not the same once the outlier is removed hence it return me the error. Is there any other way to overcome this issue?

Advertisement

Answer

You may filter for both columns at the same time,

JavaScript

In this case all three of the df, the conditions for 'humidity' and that for 'windspeed' share the same length because they are all derived from the same df.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement