I have a seemingly simple problem that I need to solve, however, I can't seem to figure out a fast, simple effective solution to it. A df
that I am dealing with looks like this:
ID type
11 payment
11 contact
11 endorse
12 payment
12 contact
13 endorse
What I am trying to achieve with my code is for each unique ID, how many types it corresponds to and what are they. So, it would look something like:
ID n_type what_types
11 3 payment, contact, endorse
12 2 payment, contact
13 1 endorse
Could someone please assist me in this problem?
Thank you so much.