i have a dataframe like
customer genre
0 cust1 |BIOPIC|DRAMA|
1 cust2 |COMEDY|DRAMA|ROMANCE|
2 cust1 |DRAMA|THRILLER|
3 cust3 |COMEDY|HORROR|
4 cust4 |HISTORY|ROMANCE|WAR|
5 cust3 |ADVENTURE|COMEDY|
6 cust2 |ACTION|DRAMA|THRILLER|
7 cust1 |CRIME|DRAMA|THRILLER|
8 cust3 |HISTORY|ROMANCE|WAR|
9 cust2 |ADVENTURE|COMEDY|
10 cust4 |BIOPIC|DRAMA|HISTORY|THRILLER|
I need = how many times each customer did transaction(customer count) and their respective genre count.Eg. cust1 DRAMA = 3, cust1 THRILLER = 2,like wise for each customer's.
I did found the each customer count by
df = df.groupby(['cust']).size()
then i know how to filter out the genres and getting the count if it was within a LIST , but i am getting confused with how to proceed with each group of customer and getting the count for each customer's indivisual genre count.
filtering(|) from genre expression and getting the fields out.
please suggest.