I have a dataframe with two columns:
df=[[5,3,1,9],[0,6,2,3],[1,5,1,8],[5,6,2,8],[2,9,11,3],[0,1,1,17]]
df=pd.DataFrame(df1, columns = ['A_june', 'A_july', 'B_june', 'B_july'])
I want to group these columns all into the same bins, namely 0-2, 2-4,4-6,6-8,8-10 and 10+ and display them in a table with counts filling these rows and columns:
Bins A_june A_july B_june B_july
0-2
2-4
4-6
6-8
...
Where I'm having trouble is if I use pd.cut, I don't know how to display it like this. I tried. basically
df=df(pd.cut(A_june,bins),pd.cut(A_july,bins))
df=df.groupby(pd.cut(A_june,bins),pd.cut(A_july,bins)).size().unstack()
But then I end up with groupby objects and similar objects that I can't do what I want with, and that don't have the right rows and columns anyway.
Thanks for any suggestions! :)