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 ( 3 years ago )
def pendiente(list_range, lista):
return np.polyfit(
list_range,
lista,
deg=1
)[0]
%%time
sklearn_test['pendiente'] = sklearn_test[[col for col in sklearn_test.columns if 'tasa_test' in col]].apply(
lambda _: pendiente(list_range, list(_)),
axis=1
)
grupos_score = ['Q4', 'Q3', 'Q2', 'Q1'][::-1]
cortes_deciles = [0, 0.25, 0.5, 0.75, 1]
sklearn_test['grupo_pendiente'] = list(
pd.qcut(sklearn_test['pendiente'], cortes_deciles, labels=grupos_score)
)
sklearn_test.groupby(by=['grupo_pendiente']).agg({
'flg_desembolso': ['count', 'mean'], 'pendiente': ['max', 'min', 'mean', 'median']
})
Revise this Paste