I have data for Loan instalment repayment by different customers.
The data includes basic details of customers like Name
, Age
, Salary
, region
, credit score
etc.
There are some time variant fields as well like outstanding balance which is updated every month (but I am not really concerned with this data).
In my data set I have 6 rows for every customer (1 for each month till past 6 months). Each row contains a column called status
(paid/not paid).
Example dataset looks as below:
Customer
Number Age Balance Status
A123 34 1000 Paid
A123 34 2000 UnPaid
A123 34 1500 UnPaid
A123 34 1400 Paid
A123 34 1300 Paid
A123 34 1400 UnPaid
A234 36 1000 Paid
A234 36 4000 Paid
A234 36 3000 UnPaid
A234 36 5000 Paid
A234 36 6000 UnPaid
A234 36 1700 Paid
I want to convert the data in below format:
Customer
Number Age Balance Status1 Status2 Status3 Status4 Status5 Status6
A123 34 1000 Paid UnPaid UnPaid Paid Paid UnPaid
A234 36 1000 Paid Paid UnPaid Paid UnPaid Paid
Please note that, I am just interested in the latest values of other columns (Age
, Balance
etc.)
I have tried the casting()
function but it did not do what I was after.
Can anyone help with this?