Comparing populations
Putting these kinds of summarizing visualizations of different populations next to one another will be useful to create visuals that help us compare those populations. This can be done with histograms, boxplots, and bar charts. Let's see how this is done using the following three examples.
Example of comparing populations using boxplots
Write some code that creates the following two boxplots next to one another:
- A boxplot of
education-num
for data objects with anincome
value that is <=50K - A boxplot of
education-num
for data objects with anincome
value that is >50K
Give the preceding example a try on your own before looking at the following code:
income_possibilities = adult_df.income.unique() for poss in income_possibilities: BM = adult_df.income == poss plt.hist(adult_df[BM]['education-num'], label=poss, histtype='step') ...