Exploring with KDE plots
Kernel Density Estimate (KDE) plots are a great alternative to histograms when you want to show multiple distributions in the same visual.
Suppose you are interested in the relationship between marriage duration and the number of kids that a couple has. Since values in the num_kids
column range only from one to five, you can plot the KDE for each value on the same plot.
The divorce
DataFrame has been loaded for you. pandas
has been loaded as pd
, matplotlib.pyplot
has been loaded as plt
, and Seaborn has been loaded as sns
. Recall that the num_kids
column in divorce
lists only N/A
values for couples with no children, so you'll only be looking at distributions for divorced couples with at least one child.
This exercise is part of the course
Exploratory Data Analysis in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create the KDE plot
____
plt.show()