QuestionQ126

VerifiedData Processing

A data scientist is using a Spark DataFrame, df, that contains numerical data. They need to remove outliers from the salary column using the Interquartile Range (IQR) method. The cleaned DataFrame must be assigned to cleaned_df.

Which approach correctly removes the outliers?

Explanation

The IQR method defines IQR as Q3 − Q1 and treats values below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR as outliers. approxQuantile returns the requested numerical-column quantiles, and filtering inclusively between these calculated lower and upper bounds preserves the non-outlier rows. PySpark DataFrame.approxQuantile documentation

Learn more

Community Discussion

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