feature-engineering-and-data-transformations/using-toy-exmaples/feature_cleaning/outlier.py
def windsorization(data,col,para,strategy='both'):
    """
    top-coding & bottom coding (capping the maximum of a distribution at an arbitrarily set value,vice versa)
    """
    
    data_copy = data.copy(deep=True)  
    if strategy == 'both':
        data_copy.loc[data_copy[col]>para[0],col] = para[0]
        data_copy.loc[data_copy[col]<para[1],col] = para[1]
    elif strategy == 'top':
        data_copy.loc[data_copy[col]>para[0],col] = para[0]
    elif strategy == 'bottom':
        data_copy.loc[data_copy[col]<para[1],col] = para[1]  
    return data_copy

    top-coding & bottom coding (capping the maximum of a distribution at an arbitrarily set value,vice versa)
    
top-coding & bottom coding (capping the maximum of a distribution at an arbitrarily set value,vice versa)
top - coding & bottom coding ( capping the maximum of a distribution at an arbitrarily set value vice versa )
def windsorization(data,col,para,strategy='both'):
    data_copy = data.copy(deep=True)  
    if strategy == 'both':
        data_copy.loc[data_copy[col]>para[0],col] = para[0]
        data_copy.loc[data_copy[col]<para[1],col] = para[1]
    elif strategy == 'top':
        data_copy.loc[data_copy[col]>para[0],col] = para[0]
    elif strategy == 'bottom':
        data_copy.loc[data_copy[col]<para[1],col] = para[1]  
    return data_copy
def windsorization ( data , col , para , strategy = 'both' ) : data_copy = data . copy ( deep = True ) if strategy == 'both' : data_copy . loc [ data_copy [ col ] > para [ 0 ] , col ] = para [ 0 ] data_copy . loc [ data_copy [ col ] < para [ 1 ] , col ] = para [ 1 ] elif strategy == 'top' : data_copy . loc [ data_copy [ col ] > para [ 0 ] , col ] = para [ 0 ] elif strategy == 'bottom' : data_copy . loc [ data_copy [ col ] < para [ 1 ] , col ] = para [ 1 ] return data_copy
top-coding & bottom coding (capping the maximum of a distribution at an arbitrarily set value,vice versa)
top - coding & bottom coding ( capping the maximum of a distribution at an arbitrarily set value vice versa )
"""
    top-coding & bottom coding (capping the maximum of a distribution at an arbitrarily set value,vice versa)
    """
data
col
para
strategy