def sum_amount_previous_loan(df):
    """
    sum previous loans amount (demanded amount and obtained amount)

    :param df: previous loans application dataframe

    :return  dataframe : SK_ID_CURR plus feature PREV_AMT_APP_SUM & PREV_AMT_CRED_SUM
    """
    df_out = df.groupby(['SK_ID_CURR'])['AMT_APPLICATION', 'AMT_CREDIT'].sum().reset_index(). \
        rename(columns={'AMT_APPLICATION': 'PREV_AMT_APP_SUM', 'AMT_CREDIT': 'PREV_AMT_CRED_SUM'})
    return df_out