MulaiMulai sekarang secara gratis

Immigration

While immigrants from foreign countries may stay for many years, we may be interested in new immigration, and how immigration is changing over time. In this exercise, you will use data from ACS Table B07410, which allows you to look specifically at movers who arrive from abroad and are not citizens –i.e. new immigrants.

The DataFrame us_immigration is loaded, and is displayed in the console. It shows new_immigrants and the total population by year, 2011-2017.

pandas and seaborn are imported using the usual aliases.

Latihan ini adalah bagian dari kursus

Analyzing US Census Data in Python

Lihat Kursus

Petunjuk latihan

  • Calculate the percent of the population that are new immigrants, using the columns new_immigrant and total
  • Create a barplot of the percent of population that are new immigrants by year

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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

# Create a barplot
sns.barplot(____, color = "cornflowerblue")
plt.show()
Edit dan Jalankan Kode