AI engineering glossary · NumPy pandas visualization

What is crosstab?

crosstab (also called contingency table): A pandas function that counts how often each combination of values from two or more categorical columns occurs, producing a frequency table. It can also normalise counts into proportions. It is a fast way to see relationships between categories.

Level: intermediateTopic: NumPy pandas visualization

crosstab: an example

pd.crosstab(df['gender'], df['bought']) counts buyers and non-buyers for each gender.

Related terms

More NumPy pandas visualization terms

Where you learn it

crosstab is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.