I have a dataset with various types of student data. I'm trying to create a pivot table that shows how many of each sex prefer a specific genre of music but right now it's just aggregating all of the M/F strings. This is the code I currently have:
pivot= df.pivot_table(index= 'Favorite_Music_Genre', values= 'Gender', aggfunc= 'sum')
And this is the output:
I assume it has something to do with 'aggfunc'. Please help!
sumbycountdf(as text so it can be copy-pasted)