earn the White PyBites Ninja earn the Yellow PyBites Ninja earn the Orange PyBites Ninja right arrow earn more PyBites Ninja belts and certificates
The best way to learn to code in Python is to actually use the language.

Our platform offers effective Test Driven Learning which will be key to your progress.

Join thousands of Pythonistas and start coding!

Join us on our PyBites Platform
Click here to code!

Code Challenge 57 - Analyze Olympic Games Data With Pandas

Posted by Andrea Mammoliti on Tue 30 October 2018 in Challenge • 2 min read

Life is about facing new challenges - Kostya Tszyu

Hey Pythonistas,

A new week, a new Python code challenge!

This week you can use Python, Pandas and all the libraries you need to analyze the data of Olympic Games and find out interesting things and present them to everyone with Matpolib, Seaborn and/or Plotly.

The Challenge

Basic/ required

Analyse statistics of Olympic Games in a CSV file that you can find on Kaggle.

  1. Find out the (male and female) athlete who won most medals in all the Summer Olympic Games (1896-2014). The answer will be Michael Phelps for the men and Larisa Latynina for the women.

  2. Display the first 10 countries that won most medals:

    • The order for men will be: USA, RUS, GBR, GER, FRA, ITA, SWE, HUN, AUS, JPN

    • The order for women will be: USA, RUS, GER, CHN, AUS, NED, ROU, GBR, JPN, HUN

  3. Use matplotlib to build line plots of the 10 most awarded countries for time span 1896-2012. Use the 10 most popular summer Olympics disciplines where most popular you can define yourself.

One requirement: use pandas to create a dataframe you can work on.

For the data visualization part, you can try matplotlib or Seaborn if you want to try a heatmap and different kind of visualizatios. You can install Jupyter (Anaconda) to work in an interactive notebook.

Don't be shy

Create a barplot which shows the total medals won for each sport during the summer Olympics.


To take this even further you could create a map and choose colors for each Country, pointing out the ones which won most medals. To get started on this, you can try plotly library, and specifically Choropleth Maps in Python.

Ideas and feedback

If you have ideas for a future challenge or find any issues, open a GH Issue or reach out directly.

Last but not least: there is no best solution, only learning more and better Python. Good luck!

Become a Python Ninja

At PyBites you get to master Python through Code Challenges:

  • Subscribe to our blog (sidebar) to get new PyBites Code Challenges (PCCs) in your inbox.

  • Apart from this blog code challenge we have a growing collection of 50+, check them out on our platform.

  • Prefer coding bite-sized Python exercises in the comfort of your browser? Try our growing collection of Bites of Py.

  • Want to do the #100DaysOfCode but not sure what to work on? Take our course and/or start logging your 100 Days progress using our Progress Grid Feature on our platform.

Keep Calm and Code in Python!

-- Andrea

See an error in this post? Please submit a pull request on Github.