ComeçarComece de graça

Rent Burden in San Francisco

In this exercise, you will look at rent burden (households paying 30% or more of their income in rent) in San Francisco, one of the highest price housing markets in the country.

The rent DataFrame contains the number of households in each of 7 income categories crossed with 8 rent-share-of-income categories. For each income category, You will use a loop to calculate the percentage of rent burdened households in each income category. The column name prefixes associated with each income category are in a list:

incomes = ["inc_under_10k", "inc_10k_to_20k", "inc_20k_to_35k", "inc_35k_to_50k",
           "inc_50k_to_75k", "inc_75k_to_100k", "inc_over_100k"]

pandas and seaborn are imported using the usual aliases.

Este exercício faz parte do curso

Analyzing US Census Data in Python

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Calculate percentage of rent burdened households
rent_burden = rent[["name"]]
for income in incomes:
    rent_burden[income] = 100 * (rent[____] + 
        rent[____] + rent[____] + 
        rent[____]) / (rent[income] - rent[income + "_rent_not_computed"])
Editar e executar o código