def pivot_table(a, b, df): return pd.pivot_table( df.loc[:, (a, b)], index=a, columns=b, aggfunc=len, fill_value=0 )