QuestionQ15

VerifiedWorking with Data and Performing Simple Analyses

You have two lists representing daily website page views and sign-ups: views = [120, 130, 128, 700, 115, 123, 119, 680, 122] and signups = [12, 15, 13, 50, 11, 14, 10, 55, 13].

You want to:

  • remove outliers (views > 600), and
  • calculate the correlation between the cleaned lists.

Which code does this correctly? Select the best answer.

Explanation

Boolean indexing selects the elements whose corresponding mask values are true. Applying the mask derived from views <= 600 to both aligned arrays removes the same outlier observations from page views and sign-ups, preserving paired data for np.corrcoef, which returns Pearson correlation coefficients.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!