Return to Video

Olympics Medal Points - Intro to Data Science

  • 0:01 - 0:03
    All right, why don't we walk through the solution.
  • 0:03 - 0:06
    Here, we're going to start with our olympic_medal_counts_df DataFrame,
  • 0:06 - 0:08
    as we have in the previous exercises.
  • 0:08 - 0:12
    First, we're going to create a new, smaller dataframe called metal counts,
  • 0:12 - 0:16
    which is the olympic_medal_count_df DataFrame, but only the gold, silver, and
  • 0:16 - 0:17
    bronze columns.
  • 0:18 - 0:22
    Then we're going to use the numpy.dot function to matrix multiply this
  • 0:22 - 0:27
    metal_counts_matrix with the 4, 2, 1 array which represents the number of
  • 0:27 - 0:30
    points that each country would score for a gold, silver, or bronze medal.
  • 0:30 - 0:33
    So what we're going to get here is an array,
  • 0:33 - 0:37
    where the value is 4 times the number of gold medals plus 2 times the number of
  • 0:37 - 0:41
    silver medals plus 1 times the number of bronze medals.
  • 0:41 - 0:45
    Down here, I'm going to define this Python dictionary called olympic_points,
  • 0:45 - 0:46
    where again I provide us the keys,
  • 0:46 - 0:50
    the column names, and as the values panda series, where I provide as
  • 0:50 - 0:55
    the argument first the list of country names and here, this array points,
  • 0:55 - 0:58
    which again has the total number of points that each country earned.
  • 0:59 - 1:06
    Finally, I'm just going to say olympic_points_df is DataFrame of olympic_points.
  • 1:06 - 1:09
    This is just the tip of the iceberg when it comes to pandas and
  • 1:09 - 1:11
    numpy's functionality.
  • 1:11 - 1:14
    If you're interested to read more about what these libraries can do,
  • 1:14 - 1:17
    I encourage you to check out the full documentation which are found in
  • 1:17 - 1:19
    the urls in the instructor comments below
Title:
Olympics Medal Points - Intro to Data Science
Description:

more » « less
Video Language:
English
Team:
Udacity
Project:
ud359: Intro to Data Science
Duration:
01:20

English subtitles

Revisions Compare revisions