I have this kind of dataframe df:
df = pd.DataFrame({'c':[1,1,2,2,3,3],'L0':['a','a','b','c','d','e'],'L1':['a','b','c','e','f','e']})
I'm now trying to get the frequency of each values in columns L0 and L1 for each value of c. The expected output would be:
c a b c d e f
1 3 1 0 0 0 0
2 0 1 2 0 1 0
3 0 0 0 1 2 1
I thought I could use something like:
df.pivot_table(index='c', columns=np.unique(['L0','L1']), aggfunc=f)
but I can't figured out how to describe f that should be a function able to get the value_counts() over multiple columns.