text_plain_output_1.png
import numpy as np

import pandas as pd

data = pd.read_csv('/kaggle/input/housesalesprediction/kc_house_data.csv')

data.shape

data.dtypes

data.drop(['id', 'date', 'lat', 'long'], axis=1, inplace=True)

Q1 = data.quantile(0.25)
Q3 = data.quantile(0.75)
IQR = Q3 - Q1
print(IQR)
upper = data[~(data > Q3 + 1.5 * IQR)].max()
lower = data[~(data < Q1 - 1.5 * IQR)].min()
df = np.where(data > upper, data.mean(), np.where(data < lower, data.mean(), data))
data = pd.DataFrame(df, columns=data.columns)