0
0
Data Analysis Pythondata~10 mins

Correlation with corr() 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 calculate the correlation matrix of the DataFrame.

Data Analysis Python
correlation_matrix = df.[1]()
Drag options to blanks, or click blank then click option'
Amean
Bcorr
Csum
Ddescribe
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mean()' instead of 'corr()' which calculates averages, not correlations.
Using 'sum()' which adds values, not related to correlation.
2fill in blank
medium

Complete the code to calculate the correlation between columns 'A' and 'B' in the DataFrame.

Data Analysis Python
correlation = df['A'].[1](df['B'])
Drag options to blanks, or click blank then click option'
Acorr
Bmean
Csum
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mean()' which calculates average, not correlation.
Using 'sum()' which adds values, not correlation.
3fill in blank
hard

Fix the error in the code to calculate correlation matrix correctly.

Data Analysis Python
correlation_matrix = df.[1]
Drag options to blanks, or click blank then click option'
Acorr()
Bcorr
Ccorr[]
Dcorr{}
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting parentheses after 'corr' causing no calculation.
Using brackets or braces which are invalid syntax here.
4fill in blank
hard

Fill both blanks to create a dictionary of correlations for columns with correlation greater than 0.5.

Data Analysis Python
high_corr = {col: df['target'].[1](df[col]) for col in df.columns if df['target'].[2] col > 0.5}
Drag options to blanks, or click blank then click option'
Acorr
B==
C>
Dmean
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '>' which checks for equality, not greater than.
Using 'mean' instead of 'corr' which does not calculate correlation.
5fill in blank
hard

Fill all three blanks to create a filtered DataFrame with columns having correlation above 0.7 with 'score'.

Data Analysis Python
corr_matrix = df.[1]()
high_corr_cols = [col for col in corr_matrix['score'] if corr_matrix['score'][col] [2] 0.7]
filtered_df = df[[3]]
Drag options to blanks, or click blank then click option'
Acorr
B>
Chigh_corr_cols
Dmean
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mean' instead of 'corr' for correlation matrix.
Using '<' instead of '>' for filtering.
Using wrong variable name instead of the filtered column list.