Advertisement
AlexErin1308

30.03.24

Mar 30th, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | Source Code | 0 0
  1. def remove_outliers(df, column):
  2.     q1 = df[column].quantile(0.25)
  3.     q3 = df[column].quantile(0.75)
  4.     iqr = q3 - q1
  5.     lower_bound = round((q1 - 1.5*iqr), 2)
  6.     upper_bound = round((q3 + 1.5*iqr), 2)
  7.     return print(f'Межквартильный размах {column}: min {lower_bound} max {upper_bound}')
  8. list_column = ['total_area',
  9.     'rooms',
  10.     'living_area',
  11.     'last_price',
  12.     'kitchen_area',
  13.     'ceiling_height',
  14.     'floors_total',
  15.     'city_centers_nearest',
  16.     'ponds_nearest']
  17. for col in list_column:
  18.     df[col] = remove_outliers(df, col)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement