no yes female no yes male no yes male lunch see table - for summary of pivot_table methods table - pivot_table options function name description values column name or names to aggregate by default aggregates all numeric columns rows column names or other group keys to group on the rows of the resulting pivot table cols column names or other group keys to group on the columns of the resulting pivot table aggfunc aggregation function or list of functions'meanby default can be any function valid in groupby context fill_value replace missing values in result table margins add row/column subtotals and grand totalfalse by default cross-tabulationscrosstab cross-tabulation (or crosstab for shortis special case of pivot table that computes group frequencies here is canonical example taken from the wikipedia page on crosstabulationin [ ]data out[ ]sample gender female male female male male male female female male female handedness right-handed left-handed right-handed right-handed left-handed right-handed right-handed left-handed right-handed right-handed as part of some survey analysiswe might want to summarize this data by gender and handedness you could use pivot_table to do thisbut the pandas crosstab function is very convenientin [ ]pd crosstab(data genderdata handednessmargins=trueout[ ]handedness left-handed right-handed all gender female male all pivot tables and cross-tabulation www it-ebooks info