image_output_1.png
import numpy as np

import pandas as pd

data = pd.read_csv('../input/Wholesale customers data.csv')
data.shape

data.describe().T

data.Region.value_counts()

data.Channel.value_counts()

dataset = data.copy()

log_data = np.log(dataset[['Fresh', 'Milk', 'Grocery', 'Frozen', 'Detergents_Paper', 'Delicassen']].copy())

list(log_data.columns)

for k in list(log_data.columns):
    IQR = np.percentile(log_data[k], 75) - np.percentile(log_data[k], 25)
    Outlier_top = np.percentile(log_data[k], 75) + 1.5 * IQR
    Outlier_bottom = np.percentile(log_data[k], 25) - 1.5 * IQR
    log_data[k] = np.where(log_data[k] > Outlier_top, Outlier_top, log_data[k])
    log_data[k] = np.where(log_data[k] < Outlier_bottom, Outlier_bottom, log_data[k])

dataset1 = log_data.copy()
list(dataset1.columns)