ComeçarComece de graça

Labor Force Participation

Unemployment could be going down because labor force participation is decreasing, that is, fewer people are looking for work! In this exercise, you will investigate that possiblity. You will start with a DataFrame, lf_by_race, of percent labor force participation by year for 25 to 54 year olds in four racial groups (White, Black, Asian, and Hispanic) and both sexes. You will create a bar plot of labor force participation against year. In order to condition the bar plot by demographic group, you will first melt the DataFrame. The DataFrame already has suitable column names.

pandas and seaborn have been imported with the usual aliases. unemp_by_race is loaded and five columns are displayed in the console.

Este exercício faz parte do curso

Analyzing US Census Data in Python

Ver curso

Instruções do exercício

  • melt the lf_by_race DataFrame, setting var_name to "demographic" and value_name to "labor_force_participation"; can you determine the appropriate column for the id_vars parameter?
  • Call sns.barplot with the year on the x-axis and labor force participation on the y-axis; then use the hue parameter to show sex grouped by year.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Melt DataFrame by demographic group
lf_by_race = lf_by_race.melt(
        ____,
        ____,
        ____
		)

# Plot labor force particpation by group by year
sns.barplot(____)
plt.show()
Editar e executar o código