Session Ready
Exercise

Using .value_counts() for ranking

For this exercise, you will use the pandas Series method .value_counts() to determine the top 15 countries ranked by total number of medals.

Notice that .value_counts() sorts by values by default. The result is returned as a Series of counts indexed by unique entries from the original Series with values (counts) ranked in descending order.

The DataFrame has been pre-loaded for you as medals.

Instructions
100 XP
  • Extract the 'NOC' column from the DataFrame medals and assign the result to country_names. Notice that this Series has repeated entries for every medal (of any type) a country has won in any Edition of the Olympics.
  • Create a Series medal_counts by applying .value_counts() to the Series country_names.
  • Print the top 15 countries ranked by total number of medals won. This has been done for you, so hit 'Submit Answer' to see the result.