Complete the code to count the frequency of each unique value in the 'color' column.
counts = df['color'].[1]()
count() which counts non-null values but not unique frequencies.unique() which returns unique values but not counts.The value_counts() method counts how many times each unique value appears in a column.
Complete the code to get the relative frequency (proportion) of each unique value in the 'fruit' column.
relative_freq = df['fruit'].value_counts(normalize=[1])
normalize as False returns counts, not proportions.None or 0 does not activate normalization.Setting normalize=True returns the relative frequencies as proportions.
Fix the error in the code to count values in the 'city' column of DataFrame df.
counts = df.city.[1]()count_values or similar incorrect names.The correct method name is value_counts(). Other options are misspelled and cause errors.
Fill both blanks to create a dictionary of word lengths for words longer than 4 letters.
lengths = {word: [1] for word in words if len(word) [2] 4}< instead of > changes the filter condition.word instead of len(word) as dictionary value.The dictionary comprehension maps each word to its length if the word length is greater than 4.
Fill all three blanks to create a dictionary of uppercase words and their counts if count is more than 1.
result = [1]: [2] for [3] in counts if counts[[3]] > 1
word.lower() instead of uppercase keys.counts[word] incorrectly or missing the filter condition.This dictionary comprehension creates keys as uppercase words and values as their counts, filtering counts greater than 1.