Meet the hardest functions of Pandas. In this post, I teach you how to use crosstab() and the cases where you choose it over other similar functions.

I remember myself enjoying a course named “Intermediate Data Visualization with Seaborn” on DataCamp. It was teaching pretty awesome plots and methods for DV. When it came to heatmaps, the instructor, out of nowhere introduced a completely new `pandas`

function `crosstab()`

. Then, quickly said: "`crosstab()`

is a useful function that calculates cross-tabulation tables..."

I was lost right there. Obviously, my first instinct was to check out the documentation for the function. I was just starting to feel that I could handle any documentation after Matplotlib’s, and… I was wrong. Even the examples were given on `numpy`

arrays while I was supposed to create heatmaps using the damn function🤦♂️.

After I had my practice on it, I knew that this was something that others would struggle too. So, here I am writing a whole article on it.

In the last part of this article, I talked about why some courses don’t teach you advanced functions like `crosstab()`

. It is simply hard to create the context such functions will be useful in, while keeping the level of examples to beginner. Besides, most courses use small or toy datasets. The benefit of such functions is more pronounced in more complex data science environments and often used by more experienced `pandas`

users.

In this post, I teach you how to use `crosstab()`

and the cases where you choose it over other similar functions. Enjoy!

∘ Setup

∘ Pandas crosstab(), the basics

∘ Pandas crosstab() comparison with pivot_table() and groupby()

∘ Pandas crosstab(), customizing even further

∘ Pandas crosstab(), multiple groupings

You can download the notebook of this article onGitHub repo._[this_](https://github.com/BexTuychiev/medium_stories/tree/master/hardest_of_pandas2)

artificial-intelligence machine-learning programming python data-science

Practice your skills in Data Science with Python, by learning and then trying all these hands-on, interactive projects, that I have posted for you.