Segregation Begets More Segregation
You have seen that there are relatively few tracts in Chicago with a mix of African-American and other races. How do these tracts evolve over time? tracts_cook
is loaded, and you have already calculated the percent African-American in 2010. You will begin by doing the same for 1990, then calculate the percentage point change by subtracting this from the 2010 value. You will then use regplot
to plot this change against the initial (1990) value.
In order to interpret the plot, you will add a red reference line to represent "no change". regplot
also allows you to add a LOWESS curve (using lowess = True
) to indicate the local trend in the data.
pandas
and seaborn
are loaded using the usual aliases.
This exercise is part of the course
Analyzing US Census Data in Python
Exercise instructions
- Calculate the percent African-American of each tract in 1990
- Calculate the percentage point change in African-American, by subtracting the 1990 value from the 2010 value
- In order to focus on the racially mixed tracks, restrict
tracts_cook
to those tracts wherepct_black_1990
is between 30% and 70% - Plot 1990-2000 change in Black percent (y-axis) vs percent Black in 1990 (x-axis); use
lowess = True
to add a smoothed trend curve
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Calculate percent Black in 1990 and percentage point change from 1990 to 2000
tracts_cook["pct_black_1990"] = ____
tracts_cook["pct_black_change"] = ____
# Retain tracts between 30% and 70% Black in 1990
tracts_mixed = tracts_cook[(____) & (____)]
# Plot change vs. percent Black in 1990, with "no change" reference line
sns.regplot(____, ____, ____, data = tracts_mixed)
plt.plot([30, 70], [0, 0], linestyle = "--", color = "red")
plt.show()