0
0
Data Analysis Pythondata~10 mins

Chi-squared test 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 import the chi2_contingency function from scipy.stats.

Data Analysis Python
from scipy.stats import [1]
Drag options to blanks, or click blank then click option'
Achi2_contingency
Bchi_square
Ccontingency_table
Dchi2_test
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name that does not exist in scipy.stats.
Confusing the function name with similar sounding names.
2fill in blank
medium

Complete the code to create a contingency table from two categorical columns in a pandas DataFrame named df.

Data Analysis Python
contingency_table = pd.crosstab(df['Category1'], [1])
Drag options to blanks, or click blank then click option'
Adf['Count']
Bdf['Category1']
Cdf['Value']
Ddf['Category2']
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same column twice in crosstab.
Using a non-categorical column like 'Value' or 'Count'.
3fill in blank
hard

Fix the error in the code to perform the chi-squared test on the contingency table named table.

Data Analysis Python
chi2, p, dof, expected = [1](table)
Drag options to blanks, or click blank then click option'
Achi2_contingency
Bchi_test
Cchi_square
Dcontingency_test
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent function name.
Confusing the function name with similar sounding names.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length only if the length is greater than 3.

Data Analysis Python
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B<
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length.
Using the wrong comparison operator.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each key uppercased to its value only if the value is greater than 0.

Data Analysis Python
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original key instead of uppercased key.
Using the wrong comparison operator in the condition.