feature-engineering-and-data-transformations/using-toy-exmaples/feature_cleaning/missing_data.py
def impute_NA_with_end_of_distribution(data,NA_col=[]):
    """
    replacing the NA by values that are at the far end of the distribution of that variable
    calculated by mean + 3*std
    """
    
    data_copy = data.copy(deep=True)
    for i in NA_col:
        if data_copy[i].isnull().sum()>0:
            data_copy[i+'_impute_end_of_distri'] = data_copy[i].fillna(data[i].mean()+3*data[i].std())
        else:
            warn("Column %s has no missing" % i)
    return data_copy

    replacing the NA by values that are at the far end of the distribution of that variable
    calculated by mean + 3*std
    
replacing the NA by values that are at the far end of the distribution of that variable
calculated by mean + 3*std
replacing the NA by values that are at the far end of the distribution of that variable calculated by mean + 3 * std
def impute_NA_with_end_of_distribution(data,NA_col=[]):
    data_copy = data.copy(deep=True)
    for i in NA_col:
        if data_copy[i].isnull().sum()>0:
            data_copy[i+'_impute_end_of_distri'] = data_copy[i].fillna(data[i].mean()+3*data[i].std())
        else:
            warn("Column %s has no missing" % i)
    return data_copy
def impute_NA_with_end_of_distribution ( data , NA_col = [ ] ) : data_copy = data . copy ( deep = True ) for i in NA_col : if data_copy [ i ] . isnull ( ) . sum ( ) > 0 : data_copy [ i + '_impute_end_of_distri' ] = data_copy [ i ] . fillna ( data [ i ] . mean ( ) + 3 * data [ i ] . std ( ) ) else : warn ( "Column %s has no missing" % i ) return data_copy
replacing the NA by values that are at the far end of the distribution of that variable
calculated by mean + 3*std
replacing the NA by values that are at the far end of the distribution of that variable calculated by mean + 3 * std
"""
    replacing the NA by values that are at the far end of the distribution of that variable
    calculated by mean + 3*std
    """
data
NA_col