Remove Outliers in Pandas DataFrame using Percentiles
问题 I have a DataFrame df with 40 columns and many records. df: User_id | Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | Col7 |...| Col39 For each column except the user_id column I want to check for outliers and remove the whole record, if an outlier appears. For outlier detection on each row I decided to simply use 5th and 95th percentile (I know it's not the best statistical way): Code what I have so far: P = np.percentile(df.Col1, [5, 95]) new_df = df[(df.Col1 > P[0]) & (df.Col1 < P[1])] Question