0
0
SciPydata~10 mins

SciPy with Pandas for data handling - 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 scipy.stats module.

SciPy
from scipy import [1]
Drag options to blanks, or click blank then click option'
Apandas
Bscipy
Cstats
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing only scipy without .stats
Importing pandas or numpy instead
2fill in blank
medium

Complete the code to calculate the Pearson correlation coefficient between two pandas Series, x and y.

SciPy
corr, p_value = stats.pearsonr([1], y)
Drag options to blanks, or click blank then click option'
Ax
By
Cx.values
Dx.to_list()
Attempts:
3 left
💡 Hint
Common Mistakes
Passing y instead of x
Passing x.values or x.to_list() is optional but not required
3fill in blank
hard

Fix the error in the code to perform a t-test between two pandas Series, sample1 and sample2.

SciPy
t_stat, p_val = stats.ttest_ind(sample1, [1])
Drag options to blanks, or click blank then click option'
Asample1
Bsample2
Csample2.values
Dsample1.values
Attempts:
3 left
💡 Hint
Common Mistakes
Passing sample1 twice
Passing sample2.values unnecessarily
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.

SciPy
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(word) > 3
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as value
Using word > 3 which is invalid
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each uppercase word to its frequency only if frequency is greater than 1.

SciPy
{ [1]: [2] for [3], [2] in freq_dict.items() if [2] > 1 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bfreq
Cword
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using count instead of freq
Using word instead of word.upper() as key