feature-engineering-and-data-transformations/using-toy-exmaples/feature_cleaning/outlier.py
def impute_outlier_with_avg(data,col,outlier_index,strategy='mean'):
    """
    impute outlier with mean/median/most frequent values of that variable.
    """
    
    data_copy = data.copy(deep=True)
    if strategy=='mean':
        data_copy.loc[outlier_index,col] = data_copy[col].mean()
    elif strategy=='median':
        data_copy.loc[outlier_index,col] = data_copy[col].median()
    elif strategy=='mode':
        data_copy.loc[outlier_index,col] = data_copy[col].mode()[0]   
        
    return data_copy

    impute outlier with mean/median/most frequent values of that variable.
    
impute outlier with mean/median/most frequent values of that variable.
impute outlier with mean / median / most frequent values of that variable .
def impute_outlier_with_avg(data,col,outlier_index,strategy='mean'):
    data_copy = data.copy(deep=True)
    if strategy=='mean':
        data_copy.loc[outlier_index,col] = data_copy[col].mean()
    elif strategy=='median':
        data_copy.loc[outlier_index,col] = data_copy[col].median()
    elif strategy=='mode':
        data_copy.loc[outlier_index,col] = data_copy[col].mode()[0]   
    return data_copy
def impute_outlier_with_avg ( data , col , outlier_index , strategy = 'mean' ) : data_copy = data . copy ( deep = True ) if strategy == 'mean' : data_copy . loc [ outlier_index , col ] = data_copy [ col ] . mean ( ) elif strategy == 'median' : data_copy . loc [ outlier_index , col ] = data_copy [ col ] . median ( ) elif strategy == 'mode' : data_copy . loc [ outlier_index , col ] = data_copy [ col ] . mode ( ) [ 0 ] return data_copy
impute outlier with mean/median/most frequent values of that variable.
impute outlier with mean / median / most frequent values of that variable .
"""
    impute outlier with mean/median/most frequent values of that variable.
    """
data
col
outlier_index
strategy