0

I have a dataframe of defaulted clients and their debt amounts, credit loans. The df has 558 entries, but only 350 unique clients. I want to group by and plot all kind of charts- build a typical "bad" client profile. I need to group by client id. A customer may have several defaulted loans.

clients = df_defaulted.groupby(['client_id'])

but it's not a df, it's a groupby object! How to use agg and other functions to get insights and plot charts? I only have drawn basic charts and they include repeating clients data - distribution by age, loan amount. there is repeating data crippling in my charts.

How to turn to normal df a groupby object and use aggregate functions?

ERJAN
  • 23,696
  • 23
  • 72
  • 146

1 Answers1

1

You can either use the apply or agg function on top of your groupby objects.

Something like:

df_defaulted.groupby(['client_id'])['debt amounts'].sum()
df_defaulted.groupby(['client_id']).agg(Bad_Debet_Count=('client_id', 'size')

Without saying your data, it's hard to help you further.

Allen Qin
  • 19,507
  • 8
  • 51
  • 67