My current pandas crosstab is repeating the crosstab laterally (column wise) per metric. I would like to have the metrics repeated row-wise per row column category instead. The below illustration (current output vs desired output) shows the structural change I’m after. Appreciate your advice.
Here’s my code:
pd.crosstab([df.var1,df.var2], [df.var3], values=df.values_var, aggfunc=[len, np.mean])
Here’s my illustration: