Code Challenge 57 - Analyze Olympic Games Data With Pandas

Andrea Mammoliti, Tue 30 October 2018, Challenge

Anaconda, challenges, code challenge, csv, Jupyter, Kaggle, matplotlib, Olympic Games, Pandas, Plotly, Seaborn, statistics

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:

Keep Calm and Code in Python!

-- Andrea

PyBites Python Tips

Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.

Get our Python Tips Book

"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H

"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B

"This is now my favourite first Python go-to reference." - Anthony L

"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S

Get the book