Cross-tabulation Deep Dive
Explore some more of the cross-tabulation functionalities using the presidential data.
Cross-tabulation summaries
Using the JetBrains dataset, let’s summarize the count of respondents by country and age:
Press + to interact
jb2 = tweak_jb(jb)print(pd.crosstab(index=jb2.country_live, columns=jb2.age))
Adding margins
Both pivot_table
and crosstab
have a margins parameter that will put in a column and row at the right and at the bottom, respectively, which would summarize the data:
Press + to interact
print(pd.crosstab(index=jb2.country_live, columns=jb2.age,margins=True))
Normalizing results
The ...