Last Updated on April 20, 2023 by mishou
I. The sample data set

II. Grouped by nationality

III. MultiIndex Columns flattened

You can see the code here on Google Colaboratory:
https://colab.research.google.com/drive/1Wg3VBWwA1Rg-il41inVCnVB7Aoo53bLz?usp=sharing
You can learn more about how to flatten multiIndex columns and rows from the post linked below:
How to flatten MultiIndex Columns and Rows in Pandas