ComeçarComece de graça

Characteristics of Segregated Metros

So, you've determined that segregation is higher in Northern industrialized metro areas. But these are also large, diverse metro areas. Are low diversity cities just getting a pass? Let's compare how size and diversity correlate with metropolitan segregation.

The msa DataFrame, as modified previously with the addition of the Index of Dissimilarity, has been loaded. The columns are listed in the console. Total population appears in the population column.

pandas and seaborn have been loaded using the usual aliases.

Este exercício faz parte do curso

Analyzing US Census Data in Python

Ver curso

Instruções do exercício

  • Plot segregation on the y-axis vs. metropolitan population on the x-axis
  • Calculate the percentage African-American, and assign to column black_pct
  • Plot segregation vs. percentage African-American
  • Create a scatterplot of segregation vs. percentage African-American. Add the size and hue parameters, both set to the column "population"

Exercício interativo prático

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

# Are large metros more segregated?
sns.lmplot(x = ____, y = ____, data = msa)
plt.show()

# Calculate percentage African-American
msa["black_pct"] = ____

# Are more diverse metros more segregated?
sns.lmplot(____, ____, data = msa)
plt.show()

# Display metro size, percent Black, and segregation in one plot
sns.scatterplot(____, data = msa)
plt.show()
Editar e executar o código