I have a simple Dataframe that looks like this:
DRUNK_DR state
11418 0 Indiana
2129 0 California
17876 0 Nebraska
26033 0 Tennessee
25278 0 South Carolina
10565 0 Illinois
30017 0 Vermont
19079 1 New Mexico
21159 0 North Carolina
22620 0 Oklahoma
DRUNK_DR may be 0 1 2 3
(drunk['DRUNK_DR'].unique()
array([1, 0, 2, 3]))
I would like to get a separate number and group as of state.
Example:
Alabama
0 12121
1 234
2 33
3 9
What is the best way to do this? I tried the following:
drunk.groupby(['state', 'DRUNK_DR']).count()
Does not work:
state DRUNK_DR
Alabama 0
1
2
source
share