churn_library.py
def encoder_helper(data_df, category_lst, response='Churn'):
    '''
    helper function to turn each categorical column into a new column with
    propotion of churn for each category - associated with cell 15 from the
    notebook.

    input:
        data_df: pandas dataframe
        category_lst: list of columns that contain categorical features
        response: string of response name [optional argument that could be
                used for naming variables or index y column]

    output:
        data_df: pandas dataframe with new columns for
    '''

    for category in category_lst:
        propotion_vals = []
        groups = data_df.groupby(category).mean()['Churn']

        for val in data_df[category]:
            propotion_vals.append(groups.loc[val])

        new_column_name = category + '_' + response
        data_df[new_column_name] = propotion_vals

    return data_df

    helper function to turn each categorical column into a new column with
    propotion of churn for each category - associated with cell 15 from the
    notebook.

    input:
        data_df: pandas dataframe
        category_lst: list of columns that contain categorical features
        response: string of response name [optional argument that could be
                used for naming variables or index y column]

    output:
        data_df: pandas dataframe with new columns for
    
helper function to turn each categorical column into a new column with
propotion of churn for each category - associated with cell 15 from the
notebook.

pandas dataframe
category_lst: list of columns that contain categorical features
response: string of response name [optional argument that could be
used for naming variables or index y column]

pandas dataframe with new columns for
helper function to turn each categorical column into a new column with propotion of churn for each category - associated with cell 15 from the notebook . pandas dataframe category_lst : list of columns that contain categorical features response : string of response name [ optional argument that could be used for naming variables or index y column ] pandas dataframe with new columns for
def encoder_helper(data_df, category_lst, response='Churn'):
    for category in category_lst:
        propotion_vals = []
        groups = data_df.groupby(category).mean()['Churn']
        for val in data_df[category]:
            propotion_vals.append(groups.loc[val])
        new_column_name = category + '_' + response
        data_df[new_column_name] = propotion_vals
    return data_df
def encoder_helper ( data_df , category_lst , response = 'Churn' ) : for category in category_lst : propotion_vals = [ ] groups = data_df . groupby ( category ) . mean ( ) [ 'Churn' ] for val in data_df [ category ] : propotion_vals . append ( groups . loc [ val ] ) new_column_name = category + '_' + response data_df [ new_column_name ] = propotion_vals return data_df
helper function to turn each categorical column into a new column with
propotion of churn for each category - associated with cell 15 from the
notebook.
helper function to turn each categorical column into a new column with propotion of churn for each category - associated with cell 15 from the notebook .
'''
    helper function to turn each categorical column into a new column with
    propotion of churn for each category - associated with cell 15 from the
    notebook.

    input:
        data_df: pandas dataframe
        category_lst: list of columns that contain categorical features
        response: string of response name [optional argument that could be
                used for naming variables or index y column]

    output:
        data_df: pandas dataframe with new columns for
    '''
data_df
category_lst
response