MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Analyzing US Census Data in Python

Lihat Kursus

Petunjuk latihan

  • 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"

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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()
Edit dan Jalankan Kode