開始使用免費開始

Immigration

雖然來自國外的移民可能會居留多年,但我們可能更關心「新」移民,以及移民隨時間的變化。在本練習中,你會使用 ACS 表 B07410 的資料,這能讓你特別觀察從海外遷入且非公民的移動者——也就是新移民。

us_immigration DataFrame 已載入,並顯示在主控台。它呈現 2011–2017 年各年的 new_immigrant(新移民人數)與 total(總人口)。

已使用慣用別名匯入 pandasseaborn

本練習屬於課程

使用 Python 分析美國 Census 資料

檢視課程

練習說明

  • 使用 new_immigranttotal 欄位,計算新移民佔總人口的百分比。
  • 依年份繪製新移民人口百分比的長條圖。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Calculate new immigrants as percent of current population
us_immigration["pct_new_immigrant"] = ____

# Create a barplot
sns.barplot(____, color = "cornflowerblue")
plt.show()
編輯並執行程式碼