In [1]:
import pandas as pd
In [15]:
from io import StringIO 

data ="""Sample  Animal   Intelligence
1   Dog   Dumb
2 Dog Dumb
3   Cat Smart
4 Cat    Smart
5 Dog Smart
6 Cat Smart"""
dframe = pd.read_table(StringIO(data),sep='\s+')
In [16]:
dframe
Out[16]:
Sample Animal Intelligence
0 1 Dog Dumb
1 2 Dog Dumb
2 3 Cat Smart
3 4 Cat Smart
4 5 Dog Smart
5 6 Cat Smart
In [19]:
# クロス集計表が作れます。
pd.crosstab(dframe.Animal,dframe.Intelligence,margins=True)
Out[19]:
Intelligence Dumb Smart All
Animal
Cat 0 3 3
Dog 2 1 3
All 2 4 6