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.
This exercise is part of the course
Analyzing US Census Data in Python
Exercise instructions
melt
thelf_by_race
DataFrame, settingvar_name
to"demographic"
andvalue_name
to"labor_force_participation"
; can you determine the appropriate column for theid_vars
parameter?- Call
sns.barplot
with the year on the x-axis and labor force participation on the y-axis; then use thehue
parameter to show sex grouped by year.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Melt DataFrame by demographic group
lf_by_race = lf_by_race.melt(
____,
____,
____
)
# Plot labor force particpation by group by year
sns.barplot(____)
plt.show()