Create new columns from aggregated categories 2

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Create new columns from aggregated categories 2


SK_ID_CURR CREDIT_ACTIVE CREDIT_TYPE

0 215354 Closed Consumer credit

1 215354 Active Credit card

2 215354 Active Consumer credit

3 215354 Active Credit card

4 215354 Active Consumer credit

5 215354 Active Credit card

6 215354 Active Consumer credit

7 162297 Closed Consumer credit

8 162297 Closed Consumer credit

9 162297 Active Credit card

10 162297 Active Credit card

11 162297 Closed Consumer credit

12 162297 Active Mortgage

13 402440 Active Consumer credit

14 238881 Closed Credit card



I have the table above. I'd like to aggregate each column per id. For example I need to count the number of active and closed credits per SK_ID_CURR, and then make a column for active_credits and closed_credits, with the counted values. And the same for CREDIT_TYPE.


SK_ID_CURR


CREDIT_TYPE



like:


SK_ID_CURR CREDIT_ACTIVE CREDIT_CLOSED CONSUMER_CREDIT CREDIT_CARD
215354 6 1 4 3









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

'Series' object is not callable Error / Statsmodels illegal variable name