首页 > 其他分享 >fpd dpd vintage 滚动率

fpd dpd vintage 滚动率

时间:2023-12-04 20:14:09浏览次数:25  
标签:fpd vintage loan else repay dpd date mob select

滚动率:

select a.loan_month,b.M1/a.C as 'C-M1',c.M2/a.C AS 'C-M2',d.M3/a.C AS 'C-M3' from
(select * from chenqianguang.GD) as a
left join
(select * from chenqianguang.GD) as b
on a.loan_month =b.loan_month and a.mob + 1=b.mob
LEFT join
(select * from chenqianguang.GD) as c
on a.loan_month =c.loan_month and a.mob + 2=c.mob
LEFT join
(select * from chenqianguang.GD) as d
on a.loan_month =d.loan_month and a.mob + 3=d.mob
group by a.loan_month

vintage:

select loan_month,mob,sum(loan_amt) as "放款金额",
sum(if(overdueday>=1,left_repay_principal,0)) as 1+剩余本金,
sum(if(overdueday>=60,left_repay_principal,0)) as 60+剩余本金,
sum(if(overdueday>=90,left_repay_principal,0)) as 90+剩余本金,
sum(if(overdueday>=30,left_repay_principal,0)) as 30+剩余本金,
sum(if(overdueday>=1,left_repay_principal,0))/sum(loan_amt) as "vintage1+",
sum(if(overdueday>=60,left_repay_principal,0))/sum(loan_amt) as "vintage60+",
sum(if(overdueday>=90,left_repay_principal,0))/sum(loan_amt) as "vintage90+",
sum(if(overdueday>=30,left_repay_principal,0))/sum(loan_amt) as "vintage30+"
from (
select loan_month,ref_nbr,mob,loan_amt,max(over_day) as overdueday,

(loan_amt - sum(
case
when (repay_date is not null and repay_date>mob_date) or repay_date is null then 0
when repay_date is not null and repay_date<=mob_date then principal_paid
else 0 end )) as left_repay_principal

from (
select *,
(case
when repay_date is null then datediff(mob_date,grace_date_new)
when repay_date is not null and principal != principal_paid then datediff(mob_date,grace_date_new)
when repay_date is not null and principal = principal_paid and mob_date < repay_date then datediff(mob_date,grace_date_new)
else 0 end
) as over_day from (
select ,date_format(loan_date,'%Y-%m') as loan_month,
((year(mob_date)-year(last_day(loan_date)))
12 +(month(mob_date)-month(last_day(loan_date)))) as mob

from
(select * from
(select jingfa_bill_no as ref_nbr,SUBSTR(loan_date,1,10) as loan_date, loan_amt from dev_risk_tmp.cf_bill_info_guest group by jingfa_bill_no,loan_date,loan_amt) as a
inner join
(select due_bill_no,curr_term,fund_prin_amt as principal,rel_fund_prin_amt as principal_paid,DATE_FORMAT(real_date,"%Y-%m-%d") as repay_date,
DATE_FORMAT(rpy_date,"%Y-%m-%d") as grace_date_new from dev_risk_tmp.cf_repay_plan_guest group by
due_bill_no,curr_term,fund_prin_amt,rel_fund_prin_amt,DATE_FORMAT(rpy_date,"%Y-%m-%d"),DATE_FORMAT(real_date,"%Y-%m-%d")) as b
on a.ref_nbr = b.due_bill_no) as c
cross join
(select '2022-12-31' as mob_date
union all
select '2023-01-31' as mob_date
union all
select '2023-02-28' as mob_date
union all
select '2023-03-31' as mob_date
union all
select '2023-04-30' as mob_date
union all
select '2023-05-31' as mob_date
union all
select '2023-06-30' as mob_date
union all
select '2023-07-31' as mob_date
union all
select '2023-08-31' as mob_date
union all
select '2023-09-30' as mob_date
union all
select '2023-10-31' as mob_date
union all
select '2023-11-30' as mob_date
union all
select '2023-12-31' as mob_date ) as d
where c.loan_date<=d.mob_date and mob_date <= CURRENT_DATE() ) as e ) f group by loan_month,ref_nbr,mob,loan_amt) as g group by loan_month,mob

dpd和fpd

select bill_no,DATEDIFF(watchday,pre_repay_date) as grance_date_diff,
(case when settle_time = '' and watchday>= pre_repay_date then DATEDIFF(watchday,pre_repay_date)
when settle_time != '' then DATEDIFF(settle_time,pre_repay_date) else 0 end) as fpd from
(select bill_no,current_period,pre_repay_amt,repayment_amt,settle_time,pre_repay_date,dict_repay_plan_status,
DATE_FORMAT(CURRENT_DATE(),"%Y/%m/%d") as watchday
from clx_loan.fund_plat_repay_plan_last where current_period = 1
group by bill_no,current_period,pre_repay_amt,repayment_amt,settle_time,pre_repay_date,dict_repay_plan_status) as a
where DATEDIFF(watchday,pre_repay_date) >0
date['people_fpd1+']=date.apply(lambda x:'还没到期'if x.people_grance_date_diff<1 else '1+' if
x.fpd>=1 else '0',axis=1)
date['people_fpd7+'] =date.apply(lambda x:'还没到期'if x.people_grance_date_diff<7 else '7+' if
x.fpd>=7 else '0-6',axis=1)
date['people_fpd15+'] =date.apply(lambda x:'还没到期'if x.people_grance_date_diff<15 else '15+' if
x.fpd>=15 else '0-14',axis=1)
date['people_fpd30+'] =date.apply(lambda x:'还没到期'if x.people_grance_date_diff<30 else '30+' if
x.fpd>=30 else '0-29',axis=1)

date['dpd1+']=date.apply(lambda x:'还没到期'if x.max_grance_date_diff<1 else '1+' if
x.DPD>=1 else '0',axis=1)
date['dpd7+'] =date.apply(lambda x:'还没到期'if x.max_grance_date_diff<7 else '7+' if
x.DPD>=7 else '0-6',axis=1)
date['dpd15+'] =date.apply(lambda x:'还没到期'if x.max_grance_date_diff<15 else '15+' if
x.DPD>=15 else '0-14',axis=1)
date['dpd30+'] =date.apply(lambda x:'还没到期'if x.max_grance_date_diff<30 else '30+' if
x.DPD>=30 else '0-29',axis=1)

data['dpd1'] = data.apply(lambda x:1 if x['dpd']>=1 else 2 if x.min_date_diff<=0 else 0,axis=1)
data['dpd15'] = data.apply(lambda x:1 if x['dpd']>=15 else 2 if x.min_date_diff<=14 else 0,axis=1)
data['dpd30'] = data.apply(lambda x:1 if x['dpd']>=30 else 2 if x.min_date_diff<=29 else 0,axis=1)
data['dpd90'] = data.apply(lambda x:1 if x['dpd']>=90 else 2 if x.min_date_diff<=89 else 0,axis=1)

data['dpd1'] = data.apply(lambda x:1 if x['dpd']>=1 else 2 if x.min_date_diff<=0 else 0,axis=1)
data['dpd15'] = data.apply(lambda x:1 if x['dpd']>=15 else 2 if x.min_date_diff<=14 else 0,axis=1)
data['dpd30'] = data.apply(lambda x:1 if x['dpd']>=30 else 2 if x.min_date_diff<=29 else 0,axis=1)
data['dpd90'] = data.apply(lambda x:1 if x['dpd']>=90 else 2 if x.min_date_diff<=89 else 0,axis=1)

第一种最垃圾不记录了
第二种,导致行增加太多
a=data2.shape[1]+1
col=data2.columns[6:a]
tmp=pd.melt(data2,id_vars=['idCard','people_fpd1+','people_fpd7+','people_fpd15+','people_fpd30+','product_name_new'],value_vars=col,var_name="变量")
tmp
第三种
fpd1 = pd.DataFrame()
fpd7 = pd.DataFrame()
fpd30 = pd.DataFrame()
for i in col:
t1 = pd.pivot_table(data=fksx1,index=[i],columns='people_fpd1+',
values='idcard',aggfunc=f).reset_index()
t1.rename(columns={i:'区间'},inplace=True)
t1['变量']=i
t1['fpd1+_rate'] = t1['1+']/(t1['1+']+t1['0'])
fpd1 = fpd1.append(t1)

标签:fpd,vintage,loan,else,repay,dpd,date,mob,select
From: https://www.cnblogs.com/chenqianguan/p/17875812.html

相关文章

  • dpdk编译-meson版
     1 依赖python3的elftools,没有的话可以这样装python3-mpipinstallpyelftools2 在dpdk根目录,使用命令mesonsetup-Dprefix=/home/tong/Code/dpdk-21.11.4/dest/-Ddefault_library=static-Dprefer_static=true-Ddisable_drivers=net/mlx4build-Dprefix指明i......
  • Running DPDK Forwarding Applications With Pktgen-DPDK
    Aspartoftheevaluationstageofourbachelorthesis,wesetupatestbedforrunningforwardingapplicationsinDPDKandwithPktgen-DPDKasthetrafficgenerator.Inthisblog,weaimtocover作为学士论文评估阶段的一部分,我们建立了一个测试平台,用于在DPDK......
  • DPDK-Pktgen Ubuntu 安装与使用
    原文链接:DPDK-PktgenUbuntu安装与使用系统及DPDK版本:系统:Ubuntu2204DPDK:21.11.1Pktgen-DPDK:22.04.1关于DPDK,其实Ubuntu的软件源中就已经包含了最新的Stable版本的DPDK,如果不想自己编译的话,直接 aptinstalldpdk 也是可以的(甚至更方便)。安装编译依赖:sudoaptinsta......
  • 一个PHP版PDF工具FPDF
    一个PHP版PDF工具FPDFThisrepositoryisonlymadeforcloningofficialFPDFreleaseswhichareavailableat:http://www.fpdf.orgTHEREWILLBENODEVELOPMENTINTHISREPOSITORY!FPDFisaPHPclasswhichallowstogeneratePDFfileswithpurePHP.FfromFPDF......
  • DPDK丢包那些事
    本文来自博客园,作者:T-BARBARIANS,博文严禁转载,转载必究! 一、前言DPDK技术原理相关的文章不胜枚举,但从实战出发,针对DPDK丢包这一类问题进行系统分析的文章还是凤毛麟角。刚好最近几个月一直在做DPDK的相关性能优化,x86和arm平台都在做。在完整经历了发现问题、分析问题......
  • DPDK-22.11.2 [五] 多进程
    dpdk支持多进程运行,不过要指定参数打开,如果没有设定,但开启第二个dpdk程序是会报错,告诉你相关系统资源被占用。EAL:Cannotcreatelockon'/var/run/dpdk/rte/config'.Isanotherprimaryprocessrunning?EAL:FATAL:CannotinitconfigEAL:Cannotinitconfigdpdk有两......
  • dpdk
    dpdk环境适配dpdk22.114.19.90-24.4.v2101.ky10.x86_64指导文档2.SystemRequirements—DataPlaneDevelopmentKit22.11.1documentation(dpdk.org)RequiredToolsandLibrariesdnfgroupinstall"DevelopmentTools"yuminstall--assumeyespython3-pippi......
  • 云服务测试DPDK
    一、DPDK的系统要求1.1x86上的BIOS的设置先决条件1.1.1 对于大多数平台,不需要特殊的BIOS设置即可使用基本的DPDK功能;1.1.2为了获得额外的HPET定时器和电源管理功能以及小数据包的高性能,可能需要更改BIOS设置;1.2DPDK编译(Ubuntu22.04)......
  • 数字预失真(DPD)小试
    前言射频功放的增益响应并非线性的,受到放大管饱和效应的影响,功放不可避免地出现非线性、甚至具有记忆效应的失真。这种非线性失真不仅产生高阶谐波,还会产生互调干扰,降低带内信噪比,影响带外信号。因此,需要一种方式减弱射频功放的非线性增益,数字预失真就是方式之一。ADI有篇文章不......
  • DPDK-22.11.2 [四] Virtio_user as Exception Path
    因为dpdk是把网卡操作全部拿到用户层,与原生系统驱动不再兼容,所以被dpdk接管的网卡从系统层面(ipa/ifconfig)无法看到,同样数据也不再经过系统内核。如果想把数据再发送到系统,就要用到virtiouser。这种把数据从dpdk再发送到内核的步骤,就叫做exceptionpath。有关virtiouser,又有一......