I have a dataframe that has the information, over time, of the occurences of two events (booking
and search
) for user ID's. It looks like this:
event user_id
booking asdf81
search frjl22
search frjl22
booking frjl22
search asdf81
I'd like to calculate two columns based on this - num_bookings
and num_searches
.
So, the output dataframe would look like this:
event user_id num_bookings num_searches
booking asdf81 1 0
search frjl22 0 1
search frjl22 0 2
booking frjl22 1 2
search asdf81 1 1
How can I achieve this in pandas?