Pandas > Calculate cross-tabluation of factors

Name
Code
Output
dataframe = pandas.DataFrame(numpy.random.randint(0,4,size=(5, 2)), columns=['C1','C2'])
print ("dataframe")
print (dataframe)
# cross-tabulation of two factors (default is a frequency table) 
aggregate = pandas.crosstab(dataframe.C1, dataframe.C2)
print ("aggregate data")
print (aggregate)
dataframe
   C1  C2
0   0   3
1   2   2
2   3   2
3   2   1
4   2   1
aggregate data
C2  1  2  3
C1         
0   0  0  1
2   2  1  0
3   0  1  0