Get startedGet started for free

Health Insurance Coverage

The Affordable Care Act went into effect in 2014. One of its goals was to increase health insurance coverage among healthy young adults. Has health insurance coverage among 19-25 year olds changed with the passage of the Affordable Care Act? Let's calculate the percentage point change in coverage by state. Then plot the change against the initial percent covered rate.

ACS Table B27022 - "Health Insurance Coverage Status By Sex By Enrollment Status For Young Adults Aged 19 To 25" has been loaded. Columns names (printed to the console) indicate breakdowns by sex (m/f), school enrollment (school/noschool) and insurance (insured/uninsured).

As a reminder, we are using percentages throughout this course.

pandas and seaborn have been imported using the usual aliases.

This exercise is part of the course

Analyzing US Census Data in Python

View Course

Exercise instructions

  • Calculate the percentage insured as 100 times the insured_total, divided by the total population
  • Create a pivot table states_pvt with rows representing states (index = "state"), columns as years (columns = "year"), and values as "pct_insured"
  • Calculate the change in percentage insured by subtracting pct_insured_2013 from pct_insured_2017
  • Plot the change in insurance rate (y) against the rate in 2013 (x)

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Calculate percent insured
states["insured_total"] = states["m_school_insured"] +  states["m_noschool_insured"] + states["f_school_insured"] + states["f_noschool_insured"]
states["pct_insured"] = ____

# Pivot the table and rename the columns
states_pvt = states.pivot(____)
states_pvt.columns = ["pct_insured_2013", "pct_insured_2017"]

# Calculate the change in insurance rates 2013 to 2017
states_pvt["pct_insured_change"] = ____

# Plot the change against initial (2013) insurance rates
sns.lmplot(x = ____, y = ____, data = states_pvt)
plt.show()
Edit and Run Code