Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Python by registered user vvillacorta ( 2 months ago )
EN TABLA DESPLIEGUE SQL:

              MAX(CASE WHEN upper(producto) in ('NUEVOS APPAS', 'NUEVOS APCONSUMO', 'NUEVOS AP', 'NUEVOS AP SUPER_AGIL', 'PAGARE CERRADO') 
                   AND upper(subproducto) NOT LIKE '%ECOSISTEMAS%' 
                   AND upper(subproducto) NOT LIKE '%IMPULSO%' then 1 else 0 end) flg_nuevos_ap,
               MAX(CASE WHEN upper(producto) in ('NUEVOS PRE') then 1 else 0 end) flg_nuevos_pre,
               MAX(CASE WHEN upper(producto) in ('IMPULSO') OR upper(subproducto) LIKE '%IMPULSO%'  then 1 else 0 end) flg_impulso,
               MAX(CASE WHEN upper(producto) in ('FINANCIAMIENTO DE VENTAS') or upper(producto) like '%DESCUENTO%' 
                   or upper(producto) like '%NEGOCIABLE%' or upper(producto) like '%FINANCIAMIENTO%' then 1 else 0 end) flg_financiamiento,
               MAX(CASE WHEN upper(producto) in ('ECOSISTEMAS') OR upper(subproducto) LIKE '%ECOSISTEMAS%' then 1 else 0 end) flg_ecosistemas,


EN EL DATSET
           CASE WHEN D.flg_nuevos_ecosistemas = 1 THEN 'ECOSISTEMAS'
                WHEN D.flg_nuevos_ap = 1 or flg_impulso = 1 THEN 'NUEVOS AP'
                WHEN D.flg_nuevos_pre = 1 THEN 'NUEVOS PRE'
                WHEN D.num_ruc is null THEN 'NUEVOS AP' -- en la nueva prediccion se toma a todos como 
            ELSE 'X' END campania_priorizada,

ANTES DE PEGAR EL SCORE:
def get_grupo_eco(val):
    if val >= 0.185075:
        return 'A'
    elif val >= 0.117474:
        return 'B'
    elif val >= 0.082220:
        return 'C'
    elif val >= 0.059863:
        return 'D'
    elif val >= 0.044800:
        return 'E'
    elif val >= 0.033438:
        return 'F'
    elif val >= 0.024693:
        return 'G'
    elif val >= 0.017749:
        return 'H'
    elif val >= 0.011366:
        return 'I'
    elif val >= 0:
        return 'J'
    else:
        return 'X'
    
def get_grupo_nap(val):
    if val >= 0.184110:
        return 'A'
    elif val >= 0.128010:
        return 'B'
    elif val >= 0.093170:
        return 'C'
    elif val >= 0.073179:
        return 'D'
    elif val >= 0.057962:
        return 'E'
    elif val >= 0.046228:
        return 'F'
    elif val >= 0.035985:
        return 'G'
    elif val >= 0.026551:
        return 'H'
    elif val >= 0.017605:
        return 'I'
    elif val >= 0:
        return 'J'
    else:
        return 'X'
    
def get_grupo_npre(val):
    if val >= 0.165757:
        return 'A'
    elif val >= 0.106954:
        return 'B'
    elif val >= 0.076289:
        return 'C'
    elif val >= 0.057084:
        return 'D'
    elif val >= 0.043207:
        return 'E'
    elif val >= 0.032458:
        return 'F'
    elif val >= 0.023657:
        return 'G'
    elif val >= 0.019902:
        return 'H'
    elif val >= 0.012715:
        return 'I'
    elif val >= 0:
        return 'J'
    else:
        return 'X'



def get_grupo(val, campania):
    if campania == 'ECOSISTEMAS':
        return get_grupo_eco(val)
    elif campania == 'NUEVOS PRE':
        return get_grupo_npre(val)
    elif campania == 'NUEVOS AP':
        return get_grupo_nap(val)
    else:
        return get_grupo_npre(val)

df['grupo_propension'] = df[['score_aceptacion', 'campania_priorizada']].apply(
    lambda _: get_grupo(_[0], _[1]), axis=1
)

 

Revise this Paste

Your Name: Code Language: