
Answer-first summary for fast verification
Answer: DataFrame.dropDuplicates(), DataFrame.distinct() and DataFrame.drop_duplicates()
The question asks for the most complete answer regarding operations that can return a DataFrame with no duplicate rows. The methods `DataFrame.distinct()`, `DataFrame.dropDuplicates()`, and `DataFrame.drop_duplicates()` are all capable of achieving this. `DataFrame.distinct()` removes duplicate rows based on all columns, while `DataFrame.dropDuplicates()` and its alias `DataFrame.drop_duplicates()` can also remove duplicates, with the latter being more Pythonic. Therefore, option E, which includes all three methods, is the most complete and correct answer.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Which of the following operations can be used to return a DataFrame with distinct rows (removing all duplicates)? Select the most comprehensive answer.
A
DataFrame.distinct()
B
DataFrame.dropDuplicates() and DataFrame.distinct()
C
DataFrame.dropDuplicates()
D
DataFrame.drop_duplicates()
E
DataFrame.dropDuplicates(), DataFrame.distinct() and DataFrame.drop_duplicates()
No comments yet.