Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to calculate the correlation matrix of the DataFrame df.
Data Analysis Python
corr_matrix = df.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
mean() or sum() instead of corr().Trying to use
describe() which gives summary statistics, not correlation.✗ Incorrect
The
corr() method calculates the correlation matrix between numerical columns in a DataFrame.2fill in blank
mediumComplete the code to import the seaborn library with its common alias.
Data Analysis Python
import [1] as sns
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing matplotlib or pandas instead of seaborn.
Not using the alias
sns.✗ Incorrect
Seaborn is commonly imported as
sns for creating statistical visualizations like heatmaps.3fill in blank
hardFix the error in the code to create a heatmap of the correlation matrix corr_matrix.
Data Analysis Python
sns.heatmap([1], annot=True, cmap='coolwarm')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the original DataFrame instead of the correlation matrix.
Passing matplotlib or unrelated variables.
✗ Incorrect
The heatmap function needs the correlation matrix as input to visualize it.
4fill in blank
hardFill both blanks to create a heatmap with a title and show the plot.
Data Analysis Python
sns.heatmap(corr_matrix, annot=True, cmap=[1]) plt.[2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an unrelated color map.
Forgetting to call
plt.show().✗ Incorrect
The
cmap parameter sets the color scheme; 'coolwarm' is common for correlations. plt.show() displays the plot.5fill in blank
hardFill all three blanks to import matplotlib, set figure size, and create a heatmap with annotations.
Data Analysis Python
import [1] as plt plt.figure(figsize=([2], 6)) sns.heatmap(corr_matrix, annot=[3], cmap='coolwarm')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing seaborn as plt.
Setting figure size with wrong values.
Not enabling annotations.
✗ Incorrect
We import
matplotlib.pyplot as plt, set figure width to 10, and enable annotations with annot=True.