How To Form A Pivot Table On Two Categorical Columns And Count For Each Index?
I have a data frame of 62 undergrads from a state university with 13 column (age, class, major, GPA, etc.) print(studentSurvey) ID Gender Age Major ... Text Messages 1
Solution 1:
Check crosstab
pd.crosstab(df['Gender'], df['Major'])
Fix your code
studentSurvey.pivot_table(index="Gender", columns="Major", values="ID", aggfunc="count")
Post a Comment for "How To Form A Pivot Table On Two Categorical Columns And Count For Each Index?"