0

I have a df like this:

    | ID | category | times |
 0  | aa |   mall   |   2   |
 1  | aa |  market  |   1   |
 2  | bb |   mall   |   1   |
 3  | cc |    bar   |   3   |
 4  | cc |   mall   |   1   |

times is how many times certain ID was in each category I need to make another df based on it, like this:

    | ID | mall | market | bar |
 0  | aa |  2   |    1   |  0  |
 0  | bb |  1   |    0   |  0  |
 0  | cc |  1   |    0   |  3  |

i.e., I need to change all entries of column category into columns and fill them with the number of times they were there. I tried A LOT of codes, none worked.

I tried A LOT of codes, none worked.

0 Answers0