QuestionQ11

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

A data scientist at a financial services company is working with a Spark DataFrame that contains transaction records. The DataFrame has millions of rows and includes columns for transaction_id, account_number, transaction_amount, and timestamp. Because of a source-system issue, some transactions were inadvertently recorded multiple times with identical data in every field. The data scientist must remove rows duplicated across all fields to ensure accurate financial reporting.

Which approach should the data scientist use to deduplicate the orders with PySpark?

Explanation

In PySpark, DataFrame.dropDuplicates() without a subset argument removes duplicate rows by considering all columns. It therefore retains one instance of each fully identical transaction record while preserving records that differ in any field.

Learn more

Community Discussion

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