Home › Forums › Main Forums › Python Forum › divide data and proper output
-
divide data and proper output
-
For divide credit score to 10 sections, I used code:
list=np.arange(0,1.1,0.1)
for i in list:
q= Loan[‘CR_Score’].quantile(i)
print(q)
the output is series:
101.0 331.0 389.0 418.0 440.0 462.0 484.0 507.0 533.0 576.0 846.0
but i want to get the output format like :
q0=101
q1=331,…..
q10=846.
How can I make it?
-
-
thank you.
this is the qcut function I used:
cr_label=range(1,11)
Crdt_seg=pd.qcut(Loan[‘CR_Score’],q=10,labels=cr_label)
Loan=Loan.assign(credit_seg=Crdt_seg.values)
Loan.groupby(‘credit_seg’).agg({‘Client_ID’:’count’})
the output is little different about client numbers in each segments compare with yours. Is there anything wrong in my code?
-
-
Log in to reply.