Vault #1: World University Rankings

In this DISCOVERY Data Science Project, you will do real data science in less than an hour and you will earn this project's card to your collection when you fully complete this project! ๐ŸŽ‰

Data Source: The Times Higher Education

There are hundreds of organizations that rank universities, including US News and World Report, QS World University Rankings, Times Higher Education (THE), and many others.

The Times Higher Education (THE) provides a clean, well-documented CSV that includes their rankings based on the "performance data on universities for students and their families, academics, university leaders, governments and industry". Their 2020 dataset includes almost 1,400 universities across 92 countries and includes 13 performance indicators that measure an institutionโ€™s performance across teaching, research, knowledge transfer and international outlook. Their website with additional details on this dataset is found here: https://www.timeshighereducation.com/content/world-university-rankings

In this Project, you will explore basic DataFrame operations on the Times Higher Education university rankings.

Part 1: Importing the World University Rank Dataset

Use pandas' read_csv function to read the World_University_Rank_2020.csv (already provided for you) and store that data into a DataFrame called df:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)
โš™๏ธ Test Case: Part 1: Importing the World University Rank Dataset

Part 2: Rankings with the United States

In this dataset, each row represents one university.

Find the variable that encodes where the university is located. Using a conditional, create a new DataFrame called df_US that includes the subset of data containing only the universities in the United States:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)
โš™๏ธ Test Case: Part 2: Rankings with the United States

Key Idea: Indexes

By default, pandas creates an index column that will always start with the index 0. Each row after the first receives an index in an increasing order (the second row has index 1, the third row index 2, and so on).

The Top University in the full original dataset, Oxford, has an index of 0. Using the full original dataset (df), df.loc[0] will display the row at the index (or loc) 0. See this yourself in running the following code:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Part 2.1: Indexes after Row Selection

Our dataset of US-based universities -- df_US -- is a subset of the original full dataset and still has the original index values.

When we attempt to find index 0 of df_US, we expect to get a KeyError indicating that this index does NOT exist within df_US. Try this yourself:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Part 2.2: Fix The KeyError
โš ๏ธโš ๏ธ You MUST Do This for Grading to Work โš ๏ธโš ๏ธ

In the above cell, fix the error by updating the code to select the best University in df_US.

Fix it and re-run the cell before you continue to the next puzzle.

Make certain your cell does not contain an error before you continue to the next section. :)

Part 2.3: Re-indexing the Universities in the United States

The command df_US.reset_index() can be used to regenerate the indexes for df_US.

When you run reset_index, the pandas library will:

  1. Move the existing indexes to a new column called index
  2. Then, replace all of the indexes in df_US with a new index (starting with 0, and counting up by one for each row, just like it was a new dataset)

Use the reset_index() function on df_US to reset the indexes:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)
โš™๏ธ Test Case: Part 2.3: Re-indexing the universities in the United States

Part 3: Large Universities in the United States

In the United States, there are generally large universities (often "large state schools") and small universities (often "small liberal arts colleges"). Explore the dataset and find the variable that stores the number of students that attends each university.

For the next analysis, we want to focus only on large universities in the United States. For the purpose of this analysis, we'll refer to any University with at least 30,000 students as "large".

Create a new DataFrame called df_US_large, which contains all large universities in the United States:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)
โš™๏ธ Test Case: Part 3: Large universities in the United States

Puzzle 3.1: Creating a Ranking List of Large US Universities

In the THE dataset, the dataset provides a Score_Rank column that contains the global rank of each school. For our analysis, we want to add a new column called US_large_rank that contains the ranking of large schools in the United States. There are several ways to do this, but one of the easiest is to use the reset_index() function.

There's three observations we can make:

  • Since the list is already sorted, we know the first university in df_US_large is the top university (Rank #1). The second row is Rank #2, and so on.
  • If we use reset_index, pandas will re-index the rows starting from zero.
  • The first row is index 0, which will be Rank #1, so we'd just need to add one to all the index values!

Complete the following two steps:

  1. Use reset_index() to reset the index values of df_US_large,
  2. Then, create a new column in df_US_large called "US_large_rank" with the value: df_US_large.index + 1.
Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)
Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Viewing the Top Large Schools

After all that work, let's check out the top 10 large universities in the United States:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)
โš™๏ธ Test Case: Part 3.1: Using the index to store a US_large_rank

Part 4: Creating Random Subsets

Instead of focusing on just a subset of a DataFrame, researchers often need to look at a random sample of a DataFrame.

Returning to the original dataset of nearly 1,400 universities, create one new DataFrame, df_random_15 , that gives us a random sample of 15 rows in the dataset.

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)
โš™๏ธ Test Case: Part 4: Creating random subsets

Validate and Complete This Project!

Congratulations on finishing this DISCOVERY Data Science Project! ๐ŸŽ‰๐ŸŽ‰

To validate your entire project, your entire code will run from top-to-bottom on this page and each test case will be validated one final time. If everything looks good, you'll earn the card for completing this project: