Spaces:
Sleeping
Sleeping
File size: 1,657 Bytes
cbfd6d7 81e8817 cbfd6d7 81e8817 cbfd6d7 215a7b0 cbfd6d7 81e8817 cbfd6d7 81e8817 cbfd6d7 81e8817 cbfd6d7 81e8817 cbfd6d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | # analytics/monitoring_analysis.py
import pandas as pd
from metrics.vintage_metrics import (
calculate_vintage_dpd,
calculate_vintage_ncl
)
def generate_monitoring_table(df):
dpd_30_mob3 = calculate_vintage_dpd(
df=df,
mob=3,
dpd_threshold=30,
metric_type="count"
)
dpd_30_mob6 = calculate_vintage_dpd(
df=df,
mob=6,
dpd_threshold=30,
metric_type="count"
)
dpd_60_mob6 = calculate_vintage_dpd(
df=df,
mob=6,
dpd_threshold=60,
metric_type="count"
)
ncl_y1 = calculate_vintage_ncl(
df=df,
mob=12
)
final_table = (
dpd_30_mob3[
["booking_vintage", "dpd_rate"]
]
.rename(
columns={
"dpd_rate": "30+@3"
}
)
)
final_table = final_table.merge(
dpd_30_mob6[
["booking_vintage", "dpd_rate"]
].rename(
columns={
"dpd_rate": "30+@6"
}
),
on="booking_vintage",
how="outer"
)
final_table = final_table.merge(
dpd_60_mob6[
["booking_vintage", "dpd_rate"]
].rename(
columns={
"dpd_rate": "60+@6"
}
),
on="booking_vintage",
how="outer"
)
final_table = final_table.merge(
ncl_y1[
["booking_vintage", "ncl_rate"]
].rename(
columns={
"ncl_rate": "Yr1_NCL"
}
),
on="booking_vintage",
how="outer"
)
return final_table |