I have a data frame with values such as:
name action time
------------------------------
Sam enters building 20:00
Chris enters building 20:15
Sam walks up stairs 20:20
Steve leaves building 20:25
James enters building 20:30
Chris takes elevator 20:32
Sam leaves building 20:35
Chris leaves building 20:40
Sam enters building 20:45
...
I want to get the counts of distinct actions, per person. This I am able to accomplish with df.groupby(['name','action'], as_index=False).size()
However, this gives me a visual, which I can't do much with. I would like to use these counts for different purposes. How can I put this data into an accessible data frame, so that I can get things like the amount of times each person entered and left the building. For example, I could call like df['name' == 'Sam' & 'action'=='enters building]
and assign that count to a variable?