시작하기무료로 시작하기

건강보험 가입률

Affordable Care Act는 2014년에 시행되었습니다. 그 목표 중 하나는 건강한 청년층의 건강보험 가입을 늘리는 것이었어요. 19–25세의 건강보험 가입률은 법 시행 이후 어떻게 변했을까요? 각 주별로 가입률의 퍼센트포인트 변화를 계산한 뒤, 초기 가입률과의 관계를 시각화해 보겠습니다.

ACS 표 B27022 - "Health Insurance Coverage Status By Sex By Enrollment Status For Young Adults Aged 19 To 25"가 로드되어 있습니다. 콘솔에 출력된 열 이름은 성별(m/f), 재학 여부(school/noschool), 그리고 보험 상태(insured/uninsured)의 세부 구성을 나타냅니다.

참고로, 이 강의 전반에서 백분율을 사용합니다.

pandasseaborn은 평소와 같은 별칭으로 이미 임포트되어 있습니다.

이 연습은 강의의 일부입니다

Python으로 미국 인구조사 데이터 분석하기

강의 보기

연습 안내

  • insured_totaltotal 인구로 나눈 값에 100을 곱해 건강보험 가입률(%)을 계산하세요.
  • 주를 행(index = "state"), 년도를 열(columns = "year"), 값은 "pct_insured"로 하는 피벗 테이블 states_pvt를 만드세요.
  • pct_insured_2017에서 pct_insured_2013을 빼서 가입률 변화(퍼센트포인트)를 계산하세요.
  • 2013년 가입률을 x, 가입률 변화를 y로 하여 변화를 시각화하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# 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()
코드 편집 및 실행