0
0
Data Analysis Pythondata~10 mins

Distribution plots (histplot, kdeplot) in Data Analysis Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a histogram of the 'age' column using seaborn.

Data Analysis Python
import seaborn as sns
import matplotlib.pyplot as plt
sns.histplot(data=df, x=[1])
plt.show()
Drag options to blanks, or click blank then click option'
A'age'
B'height'
C'score'
D'weight'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column name that does not exist in the DataFrame.
Not putting the column name in quotes.
2fill in blank
medium

Complete the code to add a kernel density estimate (KDE) plot for the 'salary' column.

Data Analysis Python
sns.kdeplot(data=df, x=[1])
plt.show()
Drag options to blanks, or click blank then click option'
A'department'
B'experience'
C'age'
D'salary'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a categorical column instead of a numeric one.
Forgetting to put the column name in quotes.
3fill in blank
hard

Fix the error in the code to plot a histogram with KDE overlay for the 'score' column.

Data Analysis Python
sns.histplot(data=df, x=[1], kde=True)
plt.show()
Drag options to blanks, or click blank then click option'
Ascore
Bdf['score']
C'score'
Dscore_col
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the column name without quotes.
Passing the entire column data instead of the column name.
4fill in blank
hard

Fill both blanks to create a histogram with KDE for the 'height' column and set the color to blue.

Data Analysis Python
sns.histplot(data=df, x=[1], kde=[2], color='blue')
plt.show()
Drag options to blanks, or click blank then click option'
A'height'
BTrue
CFalse
D'height_col'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name instead of a string for x.
Setting kde to False or forgetting it.
5fill in blank
hard

Fill all three blanks to create a KDE plot for the 'weight' column, shade the area under the curve, and set the line color to red.

Data Analysis Python
sns.kdeplot(data=df, x=[1], shade=[2], color=[3])
plt.show()
Drag options to blanks, or click blank then click option'
A'weight'
BTrue
C'red'
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Not putting the column name or color in quotes.
Setting shade to False or omitting it.