Hi I am trying to get Crosstab from a multi index variable "df" :
df.tail()
code X1 X2 X3
pays USA USA USA
desc phase phase phase
2020-01-01 a a a
2020-02-01 b c d
2020-03-01 a a b
2020-04-01 c a a
2020-05-01 d a d
I would like to get something like :
X1 X2 X3
a b c d a b c d a b c d
a
X1 b
c
d
a
X2 b
c
d
a
X3 b
c
d
where in each cell I get the number / percentage of Xi, Xj value of (a,b,c,d)
I tried :
pd.crosstab(index = df, columns = df)
but I get an error message :
ValueError: Shape of passed values is (3, 2), indices imply (605, 2)
Thanks for your help