ExamGecko
Question list
Search
Search

Question 27 - DSA-C02 discussion

Report
Export

Which Python method can be used to Remove duplicates by Data scientist?

A.
remove_duplicates()
Answers
A.
remove_duplicates()
B.
duplicates()
Answers
B.
duplicates()
C.
drop_duplicates()
Answers
C.
drop_duplicates()
D.
clean_duplicates()
Answers
D.
clean_duplicates()
Suggested answer: D

Explanation:

The drop_duplicates() method removes duplicate rows.

dataframe.drop_duplicates(subset, keep, inplace, ignore_index)

Remove duplicate rows from the DataFrame:

1. import pandas as pd

2. data = {

3. 'name': ['Peter', 'Mary', 'John', 'Mary'],

4. 'age': [50, 40, 30, 40],

5. 'qualified': [True, False, False, False]

6. }

7.

8. df = pd.DataFrame(data)

9. newdf = df.drop_duplicates()

asked 23/09/2024
Nicola Grossi
38 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first