code: def contingency_table(dataframe, rownames, colnames, margins=True):
      
      # Taking just the rownames + colnames of the dataframe
      sub_set = [rownames, colnames]
      _sub_df = dataframe[sub_set]
      return _sub_df.pivot_table(index=rownames, columns=colnames, margins=margins, aggfunc=len, fill_value=0)
docs: Contingency Table (also called Cross Tabulation)
         - Table in a matrix format that displays the (multivariate) frequency distribution of the variables
         - http://en.wikipedia.org/wiki/Contingency_table
         Args:
             rownames: the column name or list of columns names that make the keys of the rows
             colnames: the column name or list of columns names that make the keys of the columns