I prefer to use matrix multiplication for coding, because it's so much more efficient than iterating, but curious on how to do this if the dimensions are different.
I have two different dataframes
A:
Orig_vintage | |
---|---|
Q12018 | 185 |
Q22018. | 200 |
and B:
default_month | 1 | 2 | 3 |
---|---|---|---|
orig_vintage | |||
Q12018 | 0 | 25 | 35 |
Q22018 | 0 | 15 | 45 |
Q32018 | 0 | 35 | 65 |
and I'm trying to divide A through columns of B, so the B dataframe becomes (note I've rounded random percentages):
default_month | 1 | 2 | 3 |
---|---|---|---|
orig_vintage | |||
Q12018 | 0 | .03 | .04 |
Q22018 | 0 | .04 | .05 |
Q32018 | 0 | .06 | .07 |
But bottom line want to divide the monthly defaults by the total origination figure to get to a monthly default %.