Complete the code to import the scipy.stats module.
from scipy import [1]
The correct import is from scipy import stats. This imports the scipy.stats module as stats.
Complete the code to calculate the Pearson correlation coefficient between two pandas Series, x and y.
corr, p_value = stats.pearsonr([1], y)The pearsonr function accepts array-like inputs. Passing the pandas Series x directly works fine.
Fix the error in the code to perform a t-test between two pandas Series, sample1 and sample2.
t_stat, p_val = stats.ttest_ind(sample1, [1])The t-test compares two independent samples. The second argument should be the second sample, sample2.
Fill both blanks to create a dictionary comprehension that maps each word to its length only if the length is greater than 3.
{word: [1] for word in words if [2]The dictionary maps each word to its length, so the value is len(word). The condition filters words with length greater than 3, so the if condition is len(word) > 3.
Fill all three blanks to create a dictionary comprehension that maps each uppercase word to its frequency only if frequency is greater than 1.
{ [1]: [2] for [3], [2] in freq_dict.items() if [2] > 1 }The dictionary keys are uppercase words, so word.upper(). The values are frequencies, so freq. The loop variables are word and freq.