Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)
Paste
Pasted as Python by registered user vvillacorta ( 4 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