#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul  5 19:27:07 2018

@author: kazuki.onodera
"""


stats = ['min', 'mean', 'max', 'std']

stats_sum = ['min', 'mean', 'max', 'std', 'sum']

# =============================================================================
# prev
# =============================================================================

prev_num_aggregations = {
    # TODO: optimize stats
    'AMT_ANNUITY': stats,
    'AMT_APPLICATION': stats,
    'AMT_CREDIT': stats,
    'APP_CREDIT_PERC': stats,
    'AMT_DOWN_PAYMENT': stats,
    'AMT_GOODS_PRICE': stats,
    'HOUR_APPR_PROCESS_START': stats,
    'RATE_DOWN_PAYMENT': stats,
    'DAYS_DECISION': stats,
    'CNT_PAYMENT': stats,
    
    'total_debt':                             stats,
    'AMT_CREDIT-d-total_debt':                stats,
    'AMT_GOODS_PRICE-d-total_debt':           stats,
    'AMT_GOODS_PRICE-d-AMT_CREDIT':           stats,
    'AMT_ANNUITY-d-app_AMT_INCOME_TOTAL':     stats,
    'AMT_APPLICATION-d-app_AMT_INCOME_TOTAL': stats,
    'AMT_CREDIT-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL': stats,
    
    'AMT_ANNUITY-d-app_AMT_CREDIT':           stats,
    'AMT_APPLICATION-d-app_AMT_CREDIT':       stats,
    'AMT_CREDIT-d-app_AMT_CREDIT':            stats,
    'AMT_GOODS_PRICE-d-app_AMT_CREDIT':       stats,
    
    'AMT_ANNUITY-d-app_AMT_ANNUITY':          stats,
    'AMT_APPLICATION-d-app_AMT_ANNUITY':      stats,
    'AMT_CREDIT-d-app_AMT_ANNUITY':           stats,
    'AMT_GOODS_PRICE-d-app_AMT_ANNUITY':      stats,
    
    'AMT_ANNUITY-d-app_AMT_GOODS_PRICE':      stats,
    'AMT_APPLICATION-d-app_AMT_GOODS_PRICE':  stats,
    'AMT_CREDIT-d-app_AMT_GOODS_PRICE':       stats,
    'AMT_GOODS_PRICE-d-app_AMT_GOODS_PRICE':  stats,
    
    'AMT_ANNUITY-m-app_AMT_INCOME_TOTAL':      stats,
    'AMT_APPLICATION-m-app_AMT_INCOME_TOTAL':      stats,
    'AMT_CREDIT-m-app_AMT_INCOME_TOTAL':      stats,
    'AMT_GOODS_PRICE-m-app_AMT_INCOME_TOTAL':      stats,
    'AMT_ANNUITY-m-app_AMT_CREDIT':      stats,
    'AMT_APPLICATION-m-app_AMT_CREDIT':      stats,
    'AMT_CREDIT-m-app_AMT_CREDIT':      stats,
    'AMT_GOODS_PRICE-m-app_AMT_CREDIT':      stats,
    'AMT_ANNUITY-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_APPLICATION-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_CREDIT-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_GOODS_PRICE-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_ANNUITY-m-app_AMT_ANNUITY':      stats,
    'AMT_APPLICATION-m-app_AMT_ANNUITY':      stats,
    'AMT_CREDIT-m-app_AMT_ANNUITY':      stats,
    'AMT_GOODS_PRICE-m-app_AMT_ANNUITY':      stats,
    'AMT_ANNUITY-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_APPLICATION-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_CREDIT-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_GOODS_PRICE-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_ANNUITY-m-app_AMT_GOODS_PRICE':      stats,
    'AMT_APPLICATION-m-app_AMT_GOODS_PRICE':      stats,
    'AMT_CREDIT-m-app_AMT_GOODS_PRICE':      stats,
    'AMT_GOODS_PRICE-m-app_AMT_GOODS_PRICE':      stats,
    'AMT_ANNUITY-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_APPLICATION-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_CREDIT-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL':      stats,
    'AMT_GOODS_PRICE-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL':      stats,
    'nejumi':      stats,
    
    'DAYS_FIRST_DRAWING-m-app_DAYS_BIRTH': stats,
    'DAYS_FIRST_DRAWING-m-app_DAYS_EMPLOYED': stats,
    'DAYS_FIRST_DRAWING-m-app_DAYS_REGISTRATION': stats,
    'DAYS_FIRST_DRAWING-m-app_DAYS_ID_PUBLISH': stats,
    'DAYS_FIRST_DRAWING-m-app_DAYS_LAST_PHONE_CHANGE': stats,
    'DAYS_FIRST_DUE-m-app_DAYS_BIRTH': stats,
    'DAYS_FIRST_DUE-m-app_DAYS_EMPLOYED': stats,
    'DAYS_FIRST_DUE-m-app_DAYS_REGISTRATION': stats,
    'DAYS_FIRST_DUE-m-app_DAYS_ID_PUBLISH': stats,
    'DAYS_FIRST_DUE-m-app_DAYS_LAST_PHONE_CHANGE': stats,
    'DAYS_LAST_DUE_1ST_VERSION-m-app_DAYS_BIRTH': stats,
    'DAYS_LAST_DUE_1ST_VERSION-m-app_DAYS_EMPLOYED': stats,
    'DAYS_LAST_DUE_1ST_VERSION-m-app_DAYS_REGISTRATION': stats,
    'DAYS_LAST_DUE_1ST_VERSION-m-app_DAYS_ID_PUBLISH': stats,
    'DAYS_LAST_DUE_1ST_VERSION-m-app_DAYS_LAST_PHONE_CHANGE': stats,
    'DAYS_LAST_DUE-m-app_DAYS_BIRTH': stats,
    'DAYS_LAST_DUE-m-app_DAYS_EMPLOYED': stats,
    'DAYS_LAST_DUE-m-app_DAYS_REGISTRATION': stats,
    'DAYS_LAST_DUE-m-app_DAYS_ID_PUBLISH': stats,
    'DAYS_LAST_DUE-m-app_DAYS_LAST_PHONE_CHANGE': stats,
    'DAYS_TERMINATION-m-app_DAYS_BIRTH': stats,
    'DAYS_TERMINATION-m-app_DAYS_EMPLOYED': stats,
    'DAYS_TERMINATION-m-app_DAYS_REGISTRATION': stats,
    'DAYS_TERMINATION-m-app_DAYS_ID_PUBLISH': stats,
    'DAYS_TERMINATION-m-app_DAYS_LAST_PHONE_CHANGE': stats,   
    
    'DAYS_FIRST_DRAWING-d-app_DAYS_BIRTH': stats,
    'DAYS_FIRST_DRAWING-d-app_DAYS_EMPLOYED': stats,
    'DAYS_FIRST_DRAWING-d-app_DAYS_REGISTRATION': stats,
    'DAYS_FIRST_DRAWING-d-app_DAYS_ID_PUBLISH': stats,
    'DAYS_FIRST_DRAWING-d-app_DAYS_LAST_PHONE_CHANGE': stats,
    'DAYS_FIRST_DUE-d-app_DAYS_BIRTH': stats,
    'DAYS_FIRST_DUE-d-app_DAYS_EMPLOYED': stats,
    'DAYS_FIRST_DUE-d-app_DAYS_REGISTRATION': stats,
    'DAYS_FIRST_DUE-d-app_DAYS_ID_PUBLISH': stats,
    'DAYS_FIRST_DUE-d-app_DAYS_LAST_PHONE_CHANGE': stats,
    'DAYS_LAST_DUE_1ST_VERSION-d-app_DAYS_BIRTH': stats,
    'DAYS_LAST_DUE_1ST_VERSION-d-app_DAYS_EMPLOYED': stats,
    'DAYS_LAST_DUE_1ST_VERSION-d-app_DAYS_REGISTRATION': stats,
    'DAYS_LAST_DUE_1ST_VERSION-d-app_DAYS_ID_PUBLISH': stats,
    'DAYS_LAST_DUE_1ST_VERSION-d-app_DAYS_LAST_PHONE_CHANGE': stats,
    'DAYS_LAST_DUE-d-app_DAYS_BIRTH': stats,
    'DAYS_LAST_DUE-d-app_DAYS_EMPLOYED': stats,
    'DAYS_LAST_DUE-d-app_DAYS_REGISTRATION': stats,
    'DAYS_LAST_DUE-d-app_DAYS_ID_PUBLISH': stats,
    'DAYS_LAST_DUE-d-app_DAYS_LAST_PHONE_CHANGE': stats,
    'DAYS_TERMINATION-d-app_DAYS_BIRTH': stats,
    'DAYS_TERMINATION-d-app_DAYS_EMPLOYED': stats,
    'DAYS_TERMINATION-d-app_DAYS_REGISTRATION': stats,
    'DAYS_TERMINATION-d-app_DAYS_ID_PUBLISH': stats,
    'DAYS_TERMINATION-d-app_DAYS_LAST_PHONE_CHANGE': stats,    
    
    'cnt_paid':   ['min', 'mean', 'max', 'std', 'sum'],
    'cnt_paid_ratio': stats,
    'cnt_unpaid': ['min', 'mean', 'max', 'std', 'sum'],
    'amt_paid':   ['min', 'mean', 'max', 'std', 'sum'],
    'amt_unpaid': ['min', 'mean', 'max', 'std', 'sum'],
    'active':     ['min', 'mean', 'max', 'std', 'sum'],
    'completed':  ['min', 'mean', 'max', 'std', 'sum'],
    
    # diff & chng
'total_debt_diff': stats,
 'total_debt_pctchange': stats,
 'AMT_CREDIT-d-total_debt_diff': stats,
 'AMT_CREDIT-d-total_debt_pctchange': stats,
 'AMT_GOODS_PRICE-d-total_debt_diff': stats,
 'AMT_GOODS_PRICE-d-total_debt_pctchange': stats,
 'AMT_GOODS_PRICE-d-AMT_CREDIT_diff': stats,
 'AMT_GOODS_PRICE-d-AMT_CREDIT_pctchange': stats,
 'AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_APPLICATION-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_APPLICATION-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_CREDIT-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_CREDIT-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_ANNUITY-d-app_AMT_CREDIT_diff': stats,
 'AMT_ANNUITY-d-app_AMT_CREDIT_pctchange': stats,
 'AMT_APPLICATION-d-app_AMT_CREDIT_diff': stats,
 'AMT_APPLICATION-d-app_AMT_CREDIT_pctchange': stats,
 'AMT_CREDIT-d-app_AMT_CREDIT_diff': stats,
 'AMT_CREDIT-d-app_AMT_CREDIT_pctchange': stats,
 'AMT_GOODS_PRICE-d-app_AMT_CREDIT_diff': stats,
 'AMT_GOODS_PRICE-d-app_AMT_CREDIT_pctchange': stats,
 'AMT_ANNUITY-d-app_AMT_ANNUITY_diff': stats,
 'AMT_ANNUITY-d-app_AMT_ANNUITY_pctchange': stats,
 'AMT_APPLICATION-d-app_AMT_ANNUITY_diff': stats,
 'AMT_APPLICATION-d-app_AMT_ANNUITY_pctchange': stats,
 'AMT_CREDIT-d-app_AMT_ANNUITY_diff': stats,
 'AMT_CREDIT-d-app_AMT_ANNUITY_pctchange': stats,
 'AMT_GOODS_PRICE-d-app_AMT_ANNUITY_diff': stats,
 'AMT_GOODS_PRICE-d-app_AMT_ANNUITY_pctchange': stats,
 'AMT_ANNUITY-d-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_ANNUITY-d-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_APPLICATION-d-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_APPLICATION-d-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_CREDIT-d-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_CREDIT-d-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_GOODS_PRICE-d-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_GOODS_PRICE-d-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_ANNUITY-m-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_ANNUITY-m-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_APPLICATION-m-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_APPLICATION-m-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_CREDIT-m-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_CREDIT-m-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_GOODS_PRICE-m-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_GOODS_PRICE-m-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_ANNUITY-m-app_AMT_CREDIT_diff': stats,
 'AMT_ANNUITY-m-app_AMT_CREDIT_pctchange': stats,
 'AMT_APPLICATION-m-app_AMT_CREDIT_diff': stats,
 'AMT_APPLICATION-m-app_AMT_CREDIT_pctchange': stats,
 'AMT_CREDIT-m-app_AMT_CREDIT_diff': stats,
 'AMT_CREDIT-m-app_AMT_CREDIT_pctchange': stats,
 'AMT_GOODS_PRICE-m-app_AMT_CREDIT_diff': stats,
 'AMT_GOODS_PRICE-m-app_AMT_CREDIT_pctchange': stats,
 'AMT_ANNUITY-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_ANNUITY-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_APPLICATION-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_APPLICATION-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_CREDIT-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_CREDIT-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_GOODS_PRICE-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_GOODS_PRICE-m-app_AMT_CREDIT-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_ANNUITY-m-app_AMT_ANNUITY_diff': stats,
 'AMT_ANNUITY-m-app_AMT_ANNUITY_pctchange': stats,
 'AMT_APPLICATION-m-app_AMT_ANNUITY_diff': stats,
 'AMT_APPLICATION-m-app_AMT_ANNUITY_pctchange': stats,
 'AMT_CREDIT-m-app_AMT_ANNUITY_diff': stats,
 'AMT_CREDIT-m-app_AMT_ANNUITY_pctchange': stats,
 'AMT_GOODS_PRICE-m-app_AMT_ANNUITY_diff': stats,
 'AMT_GOODS_PRICE-m-app_AMT_ANNUITY_pctchange': stats,
 'AMT_ANNUITY-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_ANNUITY-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_APPLICATION-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_APPLICATION-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_CREDIT-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_CREDIT-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_GOODS_PRICE-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_GOODS_PRICE-m-app_AMT_ANNUITY-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_ANNUITY-m-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_ANNUITY-m-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_APPLICATION-m-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_APPLICATION-m-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_CREDIT-m-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_CREDIT-m-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_GOODS_PRICE-m-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_GOODS_PRICE-m-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_ANNUITY-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_ANNUITY-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_APPLICATION-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_APPLICATION-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_CREDIT-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_CREDIT-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_GOODS_PRICE-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_GOODS_PRICE-m-app_AMT_GOODS_PRICE-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 }

# =============================================================================
# POS
# =============================================================================

pos_num_aggregations = {
    # TODO: optimize stats
    'MONTHS_BALANCE': ['min', 'max', 'mean', 'size'],
    'SK_DPD': ['max', 'mean', 'std'],
    'SK_DPD_DEF': ['max', 'mean', 'std'],
    
    'CNT_INSTALMENT-m-CNT_INSTALMENT_FUTURE':  stats,
    'CNT_INSTALMENT_FUTURE-d-CNT_INSTALMENT': stats,
    
     # diff
     'SK_DPD-m-SK_DPD_DEF':          ['max', 'mean', 'std', 'sum'],
     'CNT_INSTALMENT_FUTURE_diff': stats,
     'CNT_INSTALMENT_FUTURE_pctchange': stats,
     'SK_DPD_diff': stats,
     'SK_DPD_pctchange': stats,
     'SK_DPD_DEF_diff': stats,
     'SK_DPD_DEF_pctchange': stats,
#    'SK_DPD_diff_over0':    ['max', 'mean', 'std', 'sum'],
#    'SK_DPD_diff_over5':    ['max', 'mean', 'std', 'sum'],
#    'SK_DPD_diff_over10':   ['max', 'mean', 'std', 'sum'],
#    'SK_DPD_diff_over15':   ['max', 'mean', 'std', 'sum'],
#    'SK_DPD_diff_over20':   ['max', 'mean', 'std', 'sum'],
#    'SK_DPD_diff_over25':   ['max', 'mean', 'std', 'sum'],
}

# =============================================================================
# ins
# =============================================================================

ins_num_aggregations = {
    # TODO: optimize stats
    'NUM_INSTALMENT_VERSION': ['nunique'],
    
    # app
    'DAYS_ENTRY_PAYMENT-m-app_DAYS_BIRTH': stats,
    'DAYS_ENTRY_PAYMENT-m-app_DAYS_EMPLOYED': stats,
    'DAYS_ENTRY_PAYMENT-m-app_DAYS_REGISTRATION': stats,
    'DAYS_ENTRY_PAYMENT-m-app_DAYS_ID_PUBLISH': stats,
    'DAYS_ENTRY_PAYMENT-m-app_DAYS_LAST_PHONE_CHANGE': stats,
    
    'AMT_PAYMENT-d-app_AMT_INCOME_TOTAL': stats,
    'AMT_PAYMENT-d-app_AMT_CREDIT': stats,
    'AMT_PAYMENT-d-app_AMT_ANNUITY': stats,
    'AMT_PAYMENT-d-app_AMT_GOODS_PRICE': stats,
    
    # prev
    'NUM_INSTALMENT_ratio': stats,
    'AMT_PAYMENT-d-AMT_ANNUITY': stats,
    
    'DPD': ['max', 'mean', 'sum', 'nunique'],
    'DBD': ['max', 'mean', 'sum', 'nunique'],
    'AMT_INSTALMENT': ['min', 'max', 'mean', 'sum'],
    'AMT_PAYMENT':    ['min', 'max', 'mean', 'sum'],
    'DAYS_ENTRY_PAYMENT': ['max', 'mean', 'sum'],
    'amt_ratio': stats,
    'amt_delta': stats,
    'days_weighted_delay': ['min', 'max', 'mean', 'sum'],
#    'delayed_day_over0': stats_sum,
#    'delayed_money_0': stats_sum,
#    'delayed_money_ratio_0': stats_sum,
#    'not-delayed_day_0': stats_sum,
#    'not-delayed_money_0': stats_sum,
#    'not-delayed_money_ratio_0': stats_sum,
#    'delayed_day_over5': stats_sum,
#    'delayed_money_5': stats_sum,
#    'delayed_money_ratio_5': stats_sum,
#    'not-delayed_day_5': stats_sum,
#    'not-delayed_money_5': stats_sum,
#    'not-delayed_money_ratio_5': stats_sum,
#    'delayed_day_over10': stats_sum,
#    'delayed_money_10': stats_sum,
#    'delayed_money_ratio_10': stats_sum,
#    'not-delayed_day_10': stats_sum,
#    'not-delayed_money_10': stats_sum,
#    'not-delayed_money_ratio_10': stats_sum,
#    'delayed_day_over15': stats_sum,
#    'delayed_money_15': stats_sum,
#    'delayed_money_ratio_15': stats_sum,
#    'not-delayed_day_15': stats_sum,
#    'not-delayed_money_15': stats_sum,
#    'not-delayed_money_ratio_15': stats_sum,
#    'delayed_day_over20': stats_sum,
#    'delayed_money_20': stats_sum,
#    'delayed_money_ratio_20': stats_sum,
#    'not-delayed_day_20': stats_sum,
#    'not-delayed_money_20': stats_sum,
#    'not-delayed_money_ratio_20': stats_sum,
#    'delayed_day_over25': stats_sum,
#    'delayed_money_25': stats_sum,
#    'delayed_money_ratio_25': stats_sum,
#    'not-delayed_day_25': stats_sum,
#    'not-delayed_money_25': stats_sum,
#    'not-delayed_money_ratio_25': stats_sum,
#    'delayed_day_over30': stats_sum,
#    'delayed_money_30': stats_sum,
#    'delayed_money_ratio_30': stats_sum,
#    'not-delayed_day_30': stats_sum,
#    'not-delayed_money_30': stats_sum,
#    'not-delayed_money_ratio_30': stats_sum,
#    'delayed_day_over35': stats_sum,
#    'delayed_money_35': stats_sum,
#    'delayed_money_ratio_35': stats_sum,
#    'not-delayed_day_35': stats_sum,
#    'not-delayed_money_35': stats_sum,
#    'not-delayed_money_ratio_35': stats_sum,
#    'delayed_day_over40': stats_sum,
#    'delayed_money_40': stats_sum,
#    'delayed_money_ratio_40': stats_sum,
#    'not-delayed_day_40': stats_sum,
#    'not-delayed_money_40': stats_sum,
#    'not-delayed_money_ratio_40': stats_sum,
#    'delayed_day_over45':         stats_sum,
#    'delayed_money_45':           stats_sum,
#    'delayed_money_ratio_45':     stats_sum,
#    'not-delayed_day_45':         stats_sum,
#    'not-delayed_money_45':       stats_sum,
#    'not-delayed_money_ratio_45': stats_sum,
    
}


# =============================================================================
# cre
# =============================================================================


cre_num_aggregations = {
#    # TODO: optimize stats
 'AMT_BALANCE': stats_sum,
 'AMT_CREDIT_LIMIT_ACTUAL': stats_sum,
 'AMT_DRAWINGS_ATM_CURRENT': stats_sum,
 'AMT_DRAWINGS_CURRENT': stats_sum,
 'AMT_DRAWINGS_OTHER_CURRENT': stats_sum,
 'AMT_DRAWINGS_POS_CURRENT': stats_sum,
 'AMT_INST_MIN_REGULARITY': stats_sum,
 'AMT_PAYMENT_CURRENT': stats_sum,
 'AMT_PAYMENT_TOTAL_CURRENT': stats_sum,
 'AMT_RECEIVABLE_PRINCIPAL': stats_sum,
 'AMT_RECIVABLE': stats_sum,
 'AMT_TOTAL_RECEIVABLE': stats_sum,
 'CNT_DRAWINGS_ATM_CURRENT': stats_sum,
 'CNT_DRAWINGS_CURRENT': stats_sum,
 'CNT_DRAWINGS_OTHER_CURRENT': stats_sum,
 'CNT_DRAWINGS_POS_CURRENT': stats_sum,
 'CNT_INSTALMENT_MATURE_CUM': stats_sum,
 
 'SK_DPD': stats_sum,
 'SK_DPD_DEF': stats_sum,
 
 'AMT_BALANCE-d-AMT_CREDIT_LIMIT_ACTUAL': stats_sum,
 'AMT_BALANCE-d-app_AMT_INCOME_TOTAL': stats_sum,
 'AMT_BALANCE-d-app_AMT_CREDIT': stats_sum,
 'AMT_BALANCE-d-app_AMT_ANNUITY': stats_sum,
 'AMT_BALANCE-d-app_AMT_GOODS_PRICE': stats_sum,
 'AMT_BALANCE-d-AMT_DRAWINGS_CURRENT': stats_sum,
 'AMT_DRAWINGS_CURRENT-d-AMT_CREDIT_LIMIT_ACTUAL': stats_sum,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_INCOME_TOTAL': stats_sum,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_CREDIT': stats_sum,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_ANNUITY': stats_sum,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_GOODS_PRICE': stats_sum,
 'AMT_TOTAL_RECEIVABLE-m-AMT_RECEIVABLE_PRINCIPAL': stats_sum,
 'AMT_RECEIVABLE_PRINCIPAL-d-AMT_TOTAL_RECEIVABLE': stats_sum,
 
 'SK_DPD-m-SK_DPD_DEF': stats_sum,
 'SK_DPD-m-SK_DPD_DEF_over0': stats_sum,
 'SK_DPD-m-SK_DPD_DEF_over5': stats_sum,
 'SK_DPD-m-SK_DPD_DEF_over10': stats_sum,
 'SK_DPD-m-SK_DPD_DEF_over15': stats_sum,
 'SK_DPD-m-SK_DPD_DEF_over20': stats_sum,
 'SK_DPD-m-SK_DPD_DEF_over25': stats_sum,
 
 # diff
'AMT_BALANCE_diff': stats,
 'AMT_BALANCE_pctchange': stats,
 'AMT_CREDIT_LIMIT_ACTUAL_diff': stats,
 'AMT_CREDIT_LIMIT_ACTUAL_pctchange': stats,
 'AMT_DRAWINGS_ATM_CURRENT_diff': stats,
 'AMT_DRAWINGS_ATM_CURRENT_pctchange': stats,
 'AMT_DRAWINGS_CURRENT_diff': stats,
 'AMT_DRAWINGS_CURRENT_pctchange': stats,
 'AMT_DRAWINGS_OTHER_CURRENT_diff': stats,
 'AMT_DRAWINGS_OTHER_CURRENT_pctchange': stats,
 'AMT_DRAWINGS_POS_CURRENT_diff': stats,
 'AMT_DRAWINGS_POS_CURRENT_pctchange': stats,
 'AMT_INST_MIN_REGULARITY_diff': stats,
 'AMT_INST_MIN_REGULARITY_pctchange': stats,
 'AMT_PAYMENT_CURRENT_diff': stats,
 'AMT_PAYMENT_CURRENT_pctchange': stats,
 'AMT_PAYMENT_TOTAL_CURRENT_diff': stats,
 'AMT_PAYMENT_TOTAL_CURRENT_pctchange': stats,
 'AMT_RECEIVABLE_PRINCIPAL_diff': stats,
 'AMT_RECEIVABLE_PRINCIPAL_pctchange': stats,
 'AMT_RECIVABLE_diff': stats,
 'AMT_RECIVABLE_pctchange': stats,
 'AMT_TOTAL_RECEIVABLE_diff': stats,
 'AMT_TOTAL_RECEIVABLE_pctchange': stats,
 'CNT_DRAWINGS_ATM_CURRENT_diff': stats,
 'CNT_DRAWINGS_ATM_CURRENT_pctchange': stats,
 'CNT_DRAWINGS_CURRENT_diff': stats,
 'CNT_DRAWINGS_CURRENT_pctchange': stats,
 'CNT_DRAWINGS_OTHER_CURRENT_diff': stats,
 'CNT_DRAWINGS_OTHER_CURRENT_pctchange': stats,
 'CNT_DRAWINGS_POS_CURRENT_diff': stats,
 'CNT_DRAWINGS_POS_CURRENT_pctchange': stats,
 'CNT_INSTALMENT_MATURE_CUM_diff': stats,
 'CNT_INSTALMENT_MATURE_CUM_pctchange': stats,
 'SK_DPD_diff': stats,
 'SK_DPD_pctchange': stats,
 'SK_DPD_DEF_diff': stats,
 'SK_DPD_DEF_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_BALANCE-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_CREDIT_diff': stats,
 'AMT_BALANCE-d-app_AMT_CREDIT_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_ANNUITY_diff': stats,
 'AMT_BALANCE-d-app_AMT_ANNUITY_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_BALANCE-d-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_INCOME_TOTAL_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_INCOME_TOTAL_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_CREDIT_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_CREDIT_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_ANNUITY_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_ANNUITY_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_GOODS_PRICE_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_GOODS_PRICE_pctchange': stats,
 'AMT_BALANCE-d-AMT_CREDIT_LIMIT_ACTUAL_diff': stats,
 'AMT_BALANCE-d-AMT_CREDIT_LIMIT_ACTUAL_pctchange': stats,
 'AMT_BALANCE-d-AMT_DRAWINGS_CURRENT_diff': stats,
 'AMT_BALANCE-d-AMT_DRAWINGS_CURRENT_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-AMT_CREDIT_LIMIT_ACTUAL_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-AMT_CREDIT_LIMIT_ACTUAL_pctchange': stats, 
 'AMT_TOTAL_RECEIVABLE-m-AMT_RECEIVABLE_PRINCIPAL_diff': stats,
 'AMT_TOTAL_RECEIVABLE-m-AMT_RECEIVABLE_PRINCIPAL_pctchange': stats,
 'AMT_RECEIVABLE_PRINCIPAL-d-AMT_TOTAL_RECEIVABLE_diff': stats,
 'AMT_RECEIVABLE_PRINCIPAL-d-AMT_TOTAL_RECEIVABLE_pctchange': stats,
 
 # diff diff
'AMT_BALANCE_diff_diff': stats,
 'AMT_BALANCE_diff_pctchange': stats,
 'AMT_BALANCE_pctchange_diff': stats,
 'AMT_BALANCE_pctchange_pctchange': stats,
 'AMT_CREDIT_LIMIT_ACTUAL_diff_diff': stats,
 'AMT_CREDIT_LIMIT_ACTUAL_diff_pctchange': stats,
 'AMT_CREDIT_LIMIT_ACTUAL_pctchange_diff': stats,
 'AMT_CREDIT_LIMIT_ACTUAL_pctchange_pctchange': stats,
 'AMT_DRAWINGS_ATM_CURRENT_diff_diff': stats,
 'AMT_DRAWINGS_ATM_CURRENT_diff_pctchange': stats,
 'AMT_DRAWINGS_ATM_CURRENT_pctchange_diff': stats,
 'AMT_DRAWINGS_ATM_CURRENT_pctchange_pctchange': stats,
 'AMT_DRAWINGS_CURRENT_diff_diff': stats,
 'AMT_DRAWINGS_CURRENT_diff_pctchange': stats,
 'AMT_DRAWINGS_CURRENT_pctchange_diff': stats,
 'AMT_DRAWINGS_CURRENT_pctchange_pctchange': stats,
 'AMT_DRAWINGS_OTHER_CURRENT_diff_diff': stats,
 'AMT_DRAWINGS_OTHER_CURRENT_diff_pctchange': stats,
 'AMT_DRAWINGS_OTHER_CURRENT_pctchange_diff': stats,
 'AMT_DRAWINGS_OTHER_CURRENT_pctchange_pctchange': stats,
 'AMT_DRAWINGS_POS_CURRENT_diff_diff': stats,
 'AMT_DRAWINGS_POS_CURRENT_diff_pctchange': stats,
 'AMT_DRAWINGS_POS_CURRENT_pctchange_diff': stats,
 'AMT_DRAWINGS_POS_CURRENT_pctchange_pctchange': stats,
 'AMT_INST_MIN_REGULARITY_diff_diff': stats,
 'AMT_INST_MIN_REGULARITY_diff_pctchange': stats,
 'AMT_INST_MIN_REGULARITY_pctchange_diff': stats,
 'AMT_INST_MIN_REGULARITY_pctchange_pctchange': stats,
 'AMT_PAYMENT_CURRENT_diff_diff': stats,
 'AMT_PAYMENT_CURRENT_diff_pctchange': stats,
 'AMT_PAYMENT_CURRENT_pctchange_diff': stats,
 'AMT_PAYMENT_CURRENT_pctchange_pctchange': stats,
 'AMT_PAYMENT_TOTAL_CURRENT_diff_diff': stats,
 'AMT_PAYMENT_TOTAL_CURRENT_diff_pctchange': stats,
 'AMT_PAYMENT_TOTAL_CURRENT_pctchange_diff': stats,
 'AMT_PAYMENT_TOTAL_CURRENT_pctchange_pctchange': stats,
 'AMT_RECEIVABLE_PRINCIPAL_diff_diff': stats,
 'AMT_RECEIVABLE_PRINCIPAL_diff_pctchange': stats,
 'AMT_RECEIVABLE_PRINCIPAL_pctchange_diff': stats,
 'AMT_RECEIVABLE_PRINCIPAL_pctchange_pctchange': stats,
 'AMT_RECIVABLE_diff_diff': stats,
 'AMT_RECIVABLE_diff_pctchange': stats,
 'AMT_RECIVABLE_pctchange_diff': stats,
 'AMT_RECIVABLE_pctchange_pctchange': stats,
 'AMT_TOTAL_RECEIVABLE_diff_diff': stats,
 'AMT_TOTAL_RECEIVABLE_diff_pctchange': stats,
 'AMT_TOTAL_RECEIVABLE_pctchange_diff': stats,
 'AMT_TOTAL_RECEIVABLE_pctchange_pctchange': stats,
 'CNT_DRAWINGS_ATM_CURRENT_diff_diff': stats,
 'CNT_DRAWINGS_ATM_CURRENT_diff_pctchange': stats,
 'CNT_DRAWINGS_ATM_CURRENT_pctchange_diff': stats,
 'CNT_DRAWINGS_ATM_CURRENT_pctchange_pctchange': stats,
 'CNT_DRAWINGS_CURRENT_diff_diff': stats,
 'CNT_DRAWINGS_CURRENT_diff_pctchange': stats,
 'CNT_DRAWINGS_CURRENT_pctchange_diff': stats,
 'CNT_DRAWINGS_CURRENT_pctchange_pctchange': stats,
 'CNT_DRAWINGS_OTHER_CURRENT_diff_diff': stats,
 'CNT_DRAWINGS_OTHER_CURRENT_diff_pctchange': stats,
 'CNT_DRAWINGS_OTHER_CURRENT_pctchange_diff': stats,
 'CNT_DRAWINGS_OTHER_CURRENT_pctchange_pctchange': stats,
 'CNT_DRAWINGS_POS_CURRENT_diff_diff': stats,
 'CNT_DRAWINGS_POS_CURRENT_diff_pctchange': stats,
 'CNT_DRAWINGS_POS_CURRENT_pctchange_diff': stats,
 'CNT_DRAWINGS_POS_CURRENT_pctchange_pctchange': stats,
 'CNT_INSTALMENT_MATURE_CUM_diff_diff': stats,
 'CNT_INSTALMENT_MATURE_CUM_diff_pctchange': stats,
 'CNT_INSTALMENT_MATURE_CUM_pctchange_diff': stats,
 'CNT_INSTALMENT_MATURE_CUM_pctchange_pctchange': stats,
 'SK_DPD_diff_diff': stats,
 'SK_DPD_diff_pctchange': stats,
 'SK_DPD_pctchange_diff': stats,
 'SK_DPD_pctchange_pctchange': stats,
 'SK_DPD_DEF_diff_diff': stats,
 'SK_DPD_DEF_diff_pctchange': stats,
 'SK_DPD_DEF_pctchange_diff': stats,
 'SK_DPD_DEF_pctchange_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_INCOME_TOTAL_diff_diff': stats,
 'AMT_BALANCE-d-app_AMT_INCOME_TOTAL_diff_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_INCOME_TOTAL_pctchange_diff': stats,
 'AMT_BALANCE-d-app_AMT_INCOME_TOTAL_pctchange_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_CREDIT_diff_diff': stats,
 'AMT_BALANCE-d-app_AMT_CREDIT_diff_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_CREDIT_pctchange_diff': stats,
 'AMT_BALANCE-d-app_AMT_CREDIT_pctchange_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_ANNUITY_diff_diff': stats,
 'AMT_BALANCE-d-app_AMT_ANNUITY_diff_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_ANNUITY_pctchange_diff': stats,
 'AMT_BALANCE-d-app_AMT_ANNUITY_pctchange_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_GOODS_PRICE_diff_diff': stats,
 'AMT_BALANCE-d-app_AMT_GOODS_PRICE_diff_pctchange': stats,
 'AMT_BALANCE-d-app_AMT_GOODS_PRICE_pctchange_diff': stats,
 'AMT_BALANCE-d-app_AMT_GOODS_PRICE_pctchange_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_INCOME_TOTAL_diff_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_INCOME_TOTAL_diff_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_INCOME_TOTAL_pctchange_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_INCOME_TOTAL_pctchange_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_CREDIT_diff_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_CREDIT_diff_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_CREDIT_pctchange_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_CREDIT_pctchange_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_ANNUITY_diff_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_ANNUITY_diff_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_ANNUITY_pctchange_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_ANNUITY_pctchange_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_GOODS_PRICE_diff_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_GOODS_PRICE_diff_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_GOODS_PRICE_pctchange_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-app_AMT_GOODS_PRICE_pctchange_pctchange': stats,
 'AMT_BALANCE-d-AMT_CREDIT_LIMIT_ACTUAL_diff_diff': stats,
 'AMT_BALANCE-d-AMT_CREDIT_LIMIT_ACTUAL_diff_pctchange': stats,
 'AMT_BALANCE-d-AMT_CREDIT_LIMIT_ACTUAL_pctchange_diff': stats,
 'AMT_BALANCE-d-AMT_CREDIT_LIMIT_ACTUAL_pctchange_pctchange': stats,
 'AMT_BALANCE-d-AMT_DRAWINGS_CURRENT_diff_diff': stats,
 'AMT_BALANCE-d-AMT_DRAWINGS_CURRENT_diff_pctchange': stats,
 'AMT_BALANCE-d-AMT_DRAWINGS_CURRENT_pctchange_diff': stats,
 'AMT_BALANCE-d-AMT_DRAWINGS_CURRENT_pctchange_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-AMT_CREDIT_LIMIT_ACTUAL_diff_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-AMT_CREDIT_LIMIT_ACTUAL_diff_pctchange': stats,
 'AMT_DRAWINGS_CURRENT-d-AMT_CREDIT_LIMIT_ACTUAL_pctchange_diff': stats,
 'AMT_DRAWINGS_CURRENT-d-AMT_CREDIT_LIMIT_ACTUAL_pctchange_pctchange': stats,
 'AMT_TOTAL_RECEIVABLE-m-AMT_RECEIVABLE_PRINCIPAL_diff_diff': stats,
 'AMT_TOTAL_RECEIVABLE-m-AMT_RECEIVABLE_PRINCIPAL_diff_pctchange': stats,
 'AMT_TOTAL_RECEIVABLE-m-AMT_RECEIVABLE_PRINCIPAL_pctchange_diff': stats,
 'AMT_TOTAL_RECEIVABLE-m-AMT_RECEIVABLE_PRINCIPAL_pctchange_pctchange': stats,
 'AMT_RECEIVABLE_PRINCIPAL-d-AMT_TOTAL_RECEIVABLE_diff_diff': stats,
 'AMT_RECEIVABLE_PRINCIPAL-d-AMT_TOTAL_RECEIVABLE_diff_pctchange': stats,
 'AMT_RECEIVABLE_PRINCIPAL-d-AMT_TOTAL_RECEIVABLE_pctchange_diff': stats,
 'AMT_RECEIVABLE_PRINCIPAL-d-AMT_TOTAL_RECEIVABLE_pctchange_pctchange': stats,
 }

# =============================================================================
# 
# =============================================================================


bure_num_aggregations = {
        # TODO: optimize stats
        'DAYS_CREDIT': stats_sum,
        'CREDIT_DAY_OVERDUE': stats_sum,
        'DAYS_CREDIT_ENDDATE': stats_sum,
        'DAYS_ENDDATE_FACT': stats_sum,
        'AMT_CREDIT_MAX_OVERDUE': stats_sum,
        'CNT_CREDIT_PROLONG': stats_sum,
        'AMT_CREDIT_SUM': stats_sum,
        'AMT_CREDIT_SUM_DEBT': stats_sum,
        'AMT_CREDIT_SUM_LIMIT': stats_sum,
        'AMT_CREDIT_SUM_OVERDUE': stats_sum,
        'DAYS_CREDIT_UPDATE': stats_sum,
        'AMT_ANNUITY': stats_sum,
        
        # app
        'AMT_CREDIT_SUM-d-app_AMT_INCOME_TOTAL': stats_sum,
        'AMT_CREDIT_SUM-d-app_AMT_CREDIT': stats_sum,
        'AMT_CREDIT_SUM-d-app_AMT_ANNUITY': stats_sum,
        'AMT_CREDIT_SUM-d-app_AMT_GOODS_PRICE': stats_sum,
        'AMT_CREDIT_SUM_DEBT-d-app_AMT_INCOME_TOTAL': stats_sum,
        'AMT_CREDIT_SUM_DEBT-d-app_AMT_CREDIT': stats_sum,
        'AMT_CREDIT_SUM_DEBT-d-app_AMT_ANNUITY': stats_sum,
        'AMT_CREDIT_SUM_DEBT-d-app_AMT_GOODS_PRICE': stats_sum,
        'AMT_CREDIT_SUM_LIMIT-d-app_AMT_INCOME_TOTAL': stats_sum,
        'AMT_CREDIT_SUM_LIMIT-d-app_AMT_CREDIT': stats_sum,
        'AMT_CREDIT_SUM_LIMIT-d-app_AMT_ANNUITY': stats_sum,
        'AMT_CREDIT_SUM_LIMIT-d-app_AMT_GOODS_PRICE': stats_sum,
        'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_INCOME_TOTAL': stats_sum,
        'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_CREDIT': stats_sum,
        'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_ANNUITY': stats_sum,
        'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_GOODS_PRICE': stats_sum,
        
        'DAYS_CREDIT-m-app_DAYS_BIRTH': stats_sum,
        'DAYS_CREDIT-m-app_DAYS_EMPLOYED': stats_sum,
        'DAYS_CREDIT-m-app_DAYS_REGISTRATION': stats_sum,
        'DAYS_CREDIT-m-app_DAYS_ID_PUBLISH': stats_sum,
        'DAYS_CREDIT-m-app_DAYS_LAST_PHONE_CHANGE': stats_sum,
        'DAYS_CREDIT_ENDDATE-m-app_DAYS_BIRTH': stats_sum,
        'DAYS_CREDIT_ENDDATE-m-app_DAYS_EMPLOYED': stats_sum,
        'DAYS_CREDIT_ENDDATE-m-app_DAYS_REGISTRATION': stats_sum,
        'DAYS_CREDIT_ENDDATE-m-app_DAYS_ID_PUBLISH': stats_sum,
        'DAYS_CREDIT_ENDDATE-m-app_DAYS_LAST_PHONE_CHANGE': stats_sum,
        'DAYS_ENDDATE_FACT-m-app_DAYS_BIRTH': stats_sum,
        'DAYS_ENDDATE_FACT-m-app_DAYS_EMPLOYED': stats_sum,
        'DAYS_ENDDATE_FACT-m-app_DAYS_REGISTRATION': stats_sum,
        'DAYS_ENDDATE_FACT-m-app_DAYS_ID_PUBLISH': stats_sum,
        'DAYS_ENDDATE_FACT-m-app_DAYS_LAST_PHONE_CHANGE': stats_sum,
        
        'DAYS_CREDIT-d-app_DAYS_BIRTH': stats_sum,
        'DAYS_CREDIT-d-app_DAYS_EMPLOYED': stats_sum,
        'DAYS_CREDIT-d-app_DAYS_REGISTRATION': stats_sum,
        'DAYS_CREDIT-d-app_DAYS_ID_PUBLISH': stats_sum,
        'DAYS_CREDIT-d-app_DAYS_LAST_PHONE_CHANGE': stats_sum,
        'DAYS_CREDIT_ENDDATE-d-app_DAYS_BIRTH': stats_sum,
        'DAYS_CREDIT_ENDDATE-d-app_DAYS_EMPLOYED': stats_sum,
        'DAYS_CREDIT_ENDDATE-d-app_DAYS_REGISTRATION': stats_sum,
        'DAYS_CREDIT_ENDDATE-d-app_DAYS_ID_PUBLISH': stats_sum,
        'DAYS_CREDIT_ENDDATE-d-app_DAYS_LAST_PHONE_CHANGE': stats_sum,
        'DAYS_ENDDATE_FACT-d-app_DAYS_BIRTH': stats_sum,
        'DAYS_ENDDATE_FACT-d-app_DAYS_EMPLOYED': stats_sum,
        'DAYS_ENDDATE_FACT-d-app_DAYS_REGISTRATION': stats_sum,
        'DAYS_ENDDATE_FACT-d-app_DAYS_ID_PUBLISH': stats_sum,
        'DAYS_ENDDATE_FACT-d-app_DAYS_LAST_PHONE_CHANGE': stats_sum,
        
        
        'DAYS_CREDIT_ENDDATE-m-DAYS_CREDIT': stats_sum,
        'DAYS_ENDDATE_FACT-m-DAYS_CREDIT': stats_sum,
        'DAYS_ENDDATE_FACT-m-DAYS_CREDIT_ENDDATE': stats_sum,
        'DAYS_CREDIT_UPDATE-m-DAYS_CREDIT': stats_sum,
        'DAYS_CREDIT_UPDATE-m-DAYS_CREDIT_ENDDATE': stats_sum,
        'DAYS_CREDIT_UPDATE-m-DAYS_ENDDATE_FACT': stats_sum,
        'AMT_CREDIT_SUM-m-AMT_CREDIT_SUM_DEBT': stats_sum,
        'AMT_CREDIT_SUM_DEBT-d-AMT_CREDIT_SUM': stats_sum,
        'AMT_CREDIT_SUM-m-AMT_CREDIT_SUM_DEBT-d-AMT_CREDIT_SUM_LIMIT': stats_sum,
        'AMT_CREDIT_SUM_DEBT-d-AMT_CREDIT_SUM_LIMIT': stats_sum,
        'AMT_CREDIT_SUM_DEBT-p-AMT_CREDIT_SUM_LIMIT': stats_sum,
        'AMT_CREDIT_SUM-d-debt-p-AMT_CREDIT_SUM_DEBT-p-AMT_CREDIT_SUM_LIMIT': stats_sum,
        
        # diff
        'AMT_CREDIT_MAX_OVERDUE_diff': stats,
         'AMT_CREDIT_MAX_OVERDUE_pctchange': stats,
         'CNT_CREDIT_PROLONG_diff': stats,
         'CNT_CREDIT_PROLONG_pctchange': stats,
         'AMT_CREDIT_SUM_diff': stats,
         'AMT_CREDIT_SUM_pctchange': stats,
         'AMT_CREDIT_SUM_DEBT_diff': stats,
         'AMT_CREDIT_SUM_DEBT_pctchange': stats,
         'AMT_CREDIT_SUM_LIMIT_diff': stats,
         'AMT_CREDIT_SUM_LIMIT_pctchange': stats,
         'AMT_CREDIT_SUM_OVERDUE_diff': stats,
         'AMT_CREDIT_SUM_OVERDUE_pctchange': stats,
         'DAYS_CREDIT_UPDATE_diff': stats,
         'DAYS_CREDIT_UPDATE_pctchange': stats,
         'AMT_ANNUITY_diff': stats,
         'AMT_ANNUITY_pctchange': stats,
         'AMT_CREDIT_SUM-d-app_AMT_INCOME_TOTAL_diff': stats,
         'AMT_CREDIT_SUM-d-app_AMT_INCOME_TOTAL_pctchange': stats,
         'AMT_CREDIT_SUM-d-app_AMT_CREDIT_diff': stats,
         'AMT_CREDIT_SUM-d-app_AMT_CREDIT_pctchange': stats,
         'AMT_CREDIT_SUM-d-app_AMT_ANNUITY_diff': stats,
         'AMT_CREDIT_SUM-d-app_AMT_ANNUITY_pctchange': stats,
         'AMT_CREDIT_SUM-d-app_AMT_GOODS_PRICE_diff': stats,
         'AMT_CREDIT_SUM-d-app_AMT_GOODS_PRICE_pctchange': stats,
         'AMT_CREDIT_SUM_DEBT-d-app_AMT_INCOME_TOTAL_diff': stats,
         'AMT_CREDIT_SUM_DEBT-d-app_AMT_INCOME_TOTAL_pctchange': stats,
         'AMT_CREDIT_SUM_DEBT-d-app_AMT_CREDIT_diff': stats,
         'AMT_CREDIT_SUM_DEBT-d-app_AMT_CREDIT_pctchange': stats,
         'AMT_CREDIT_SUM_DEBT-d-app_AMT_ANNUITY_diff': stats,
         'AMT_CREDIT_SUM_DEBT-d-app_AMT_ANNUITY_pctchange': stats,
         'AMT_CREDIT_SUM_DEBT-d-app_AMT_GOODS_PRICE_diff': stats,
         'AMT_CREDIT_SUM_DEBT-d-app_AMT_GOODS_PRICE_pctchange': stats,
         'AMT_CREDIT_SUM_LIMIT-d-app_AMT_INCOME_TOTAL_diff': stats,
         'AMT_CREDIT_SUM_LIMIT-d-app_AMT_INCOME_TOTAL_pctchange': stats,
         'AMT_CREDIT_SUM_LIMIT-d-app_AMT_CREDIT_diff': stats,
         'AMT_CREDIT_SUM_LIMIT-d-app_AMT_CREDIT_pctchange': stats,
         'AMT_CREDIT_SUM_LIMIT-d-app_AMT_ANNUITY_diff': stats,
         'AMT_CREDIT_SUM_LIMIT-d-app_AMT_ANNUITY_pctchange': stats,
         'AMT_CREDIT_SUM_LIMIT-d-app_AMT_GOODS_PRICE_diff': stats,
         'AMT_CREDIT_SUM_LIMIT-d-app_AMT_GOODS_PRICE_pctchange': stats,
         'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_INCOME_TOTAL_diff': stats,
         'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_INCOME_TOTAL_pctchange': stats,
         'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_CREDIT_diff': stats,
         'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_CREDIT_pctchange': stats,
         'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_ANNUITY_diff': stats,
         'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_ANNUITY_pctchange': stats,
         'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_GOODS_PRICE_diff': stats,
         'AMT_CREDIT_SUM_OVERDUE-d-app_AMT_GOODS_PRICE_pctchange': stats,
         'AMT_CREDIT_SUM-m-AMT_CREDIT_SUM_DEBT_diff': stats,
         'AMT_CREDIT_SUM-m-AMT_CREDIT_SUM_DEBT_pctchange': stats,
         'AMT_CREDIT_SUM_DEBT-d-AMT_CREDIT_SUM_diff': stats,
         'AMT_CREDIT_SUM_DEBT-d-AMT_CREDIT_SUM_pctchange': stats,
         'AMT_CREDIT_SUM-m-AMT_CREDIT_SUM_DEBT-d-AMT_CREDIT_SUM_LIMIT_diff': stats,
         'AMT_CREDIT_SUM-m-AMT_CREDIT_SUM_DEBT-d-AMT_CREDIT_SUM_LIMIT_pctchange': stats,
         'AMT_CREDIT_SUM_DEBT-d-AMT_CREDIT_SUM_LIMIT_diff': stats,
         'AMT_CREDIT_SUM_DEBT-d-AMT_CREDIT_SUM_LIMIT_pctchange': stats,
         'AMT_CREDIT_SUM_DEBT-p-AMT_CREDIT_SUM_LIMIT_diff': stats,
         'AMT_CREDIT_SUM_DEBT-p-AMT_CREDIT_SUM_LIMIT_pctchange': stats,
         'AMT_CREDIT_SUM-d-debt-p-AMT_CREDIT_SUM_DEBT-p-AMT_CREDIT_SUM_LIMIT_diff': stats,
         'AMT_CREDIT_SUM-d-debt-p-AMT_CREDIT_SUM_DEBT-p-AMT_CREDIT_SUM_LIMIT_pctchange': stats
}


# =============================================================================
# 
# =============================================================================

bb_num_aggregations = {
        'MONTHS_BALANCE': ['min', 'max', 'mean', 'sum', 'std', 'size'],
         'STATUS_0': stats, 
         'STATUS_1': stats, 
         'STATUS_2': stats,
         'STATUS_3': stats, 
         'STATUS_4': stats, 
         'STATUS_5': stats, 
         'STATUS_C': stats, 
         'STATUS_X': stats,
         }















