Q:

Counting categorical data pandas group by dataframe

I have a data frame that looks like this:
+---+-----------+----------------+-------+
|   |    uid    |      msg       | count |
+---+-----------+----------------+-------+
| 0 | 121437681 | eis            |     1 |
| 1 |  14403832 | eis            |     1 |
| 2 | 190442364 | eis            |     1 |
| 3 | 190102625 | eis            |     1 |
| 4 | 190428772 | eis_reply      |     1 |
| 5 | 190428772 | single_message |     1 |
| 6 | 190428772 | yes            |     1 |
| 7 | 190104837 | eis            |     1 |
| 8 | 144969454 | eis            |     1 |
| 9 | 190738403 | eis            |     1 |
+---+-----------+----------------+-------+

What I would like to do is count the instances of each msg for each uid.
I created a groupby object and found the count of all messages:
grouped_test = test.groupby('uid')
grouped_test.count('msg') 

But I'm not quite sure how to count each type of message for each uid.  I was thinking about creating masks and 4 separate data frames, but that doesn't seem like a n efficient way to accomplish this.
Sample data - http://www.sharecsv.com/s/16573757eb123c5b15cae4edcb7296e3/sample_data.csv

A:

Group by uid and apply value_counts to the msg column:
>>> d.groupby('uid').msg.value_counts()
uid                      
14403832   eis               1
121437681  eis               1
144969454  eis               1
190102625  eis               1
190104837  eis               1
190170637  eis               1
190428772  eis               1
           single_message    1
           yes               1
           eis_reply         1
190442364  eis               1
190738403  eis               1
190991478  single_message    1
           eis_reply         1
           yes               1
191356453  eis               1
191619393  eis               1
dtype: int64

