Complete the code to count unique values in the 'color' column of the DataFrame.
unique_colors = df['color'].[1]()
count() which counts all non-null values, not unique ones.unique() which returns unique values but does not count them.The nunique() method counts the number of unique values in a column.
Complete the code to count unique values in each column of the DataFrame.
unique_counts = df.[1]()unique() which returns arrays of unique values, not counts.value_counts() which works on Series, not DataFrame.The nunique() method applied to the whole DataFrame returns unique counts per column.
Fix the error in the code to count unique values in the 'age' column.
unique_ages = df['age'].[1]
nunique.unique() which returns unique values, not count.The nunique() method must be called with parentheses to execute and return the count.
Fill both blanks to create a dictionary with words as keys and their unique letter counts as values.
unique_letters = {word: len(set(word)) for word in [1] if len(word) [2] 3}We loop over word_list and select words longer than 3 letters to count unique letters.
Fill all three blanks to create a dictionary with uppercase words as keys and their unique letter counts as values for words longer than 4 letters.
result = [1]: [2] for [3] in words if len([3]) > 4
The dictionary comprehension uses word.upper() as keys, counts unique letters with len(set(word)), and loops over word in words.