0
0
Pandasdata~10 mins

Why duplicate detection matters in Pandas - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check for duplicate rows in the DataFrame.

Pandas
duplicates = df.[1]()
Drag options to blanks, or click blank then click option'
Aduplicated
Bdrop_duplicates
Cunique
Disnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using drop_duplicates() removes duplicates instead of identifying them.
Using unique() is for unique values, not rows.
Using isnull() checks for missing values, not duplicates.
2fill in blank
medium

Complete the code to count how many duplicate rows exist in the DataFrame.

Pandas
num_duplicates = df.duplicated().[1]()
Drag options to blanks, or click blank then click option'
Amean
Bsum
Ccount
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using count() counts all rows, not just duplicates.
Using mean() gives the fraction of duplicates, not the count.
Using size returns total number of rows.
3fill in blank
hard

Fix the error in the code to remove duplicate rows from the DataFrame.

Pandas
df_clean = df.[1](keep='first')
Drag options to blanks, or click blank then click option'
Aunique
Bduplicated
Cdrop_duplicates
Ddropna
Attempts:
3 left
💡 Hint
Common Mistakes
Using duplicated() returns a boolean Series, not a DataFrame.
Using unique() is for unique values, not rows.
Using dropna() removes missing values, not duplicates.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.

Pandas
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' filters shorter words.
Using 'word' as value stores the word, not its length.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values greater than zero.

Pandas
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'k' instead of 'k.upper()' keeps keys lowercase.
Using '<' instead of '>' filters values less than zero.
Using 'k' as value instead of 'v' stores keys as values.