Exercise

Calculate Proportions

Nationally, 55% of Hispanics identify as White and 35% identify as "Some Other Race". (You can run Line 2 in the code window to confirm this.) But there is substantial state-to-state variation, which we will now investigate. As a reminder, we will express proportions as percentages throughout this course.

pandas has been imported, the DataFrame states is loaded with population counts by race and Hispanic origin. A list, hispanic_races, has names of columns with Hispanics by race data, and is shown in the console.

Instructions

100 XP
  • Use the copy method to create a deep copy of only the hispanic_races columns in states
  • As you iterate the races in the hispanic_races list, calculate the percentage of Hispanics identifying as each race as 100 times the count of the current race divided by the total number of Hispanics.
  • Print the head of the resulting DataFrame.