Complete the code to group the DataFrame by the 'Category' column.
grouped = df.groupby([1])To group data by a single column, you pass the column name as a string to groupby(). Here, 'Category' is the correct column to group by.
Complete the code to group the DataFrame by both 'Category' and 'Region' columns.
grouped = df.groupby([1])To group by multiple columns, pass a list of column names to groupby(). The list should be inside square brackets.
Fix the error in the code to correctly group by 'Category' and calculate the mean.
result = df.groupby([1]).mean()The groupby() method expects a single column name as a string or a list of strings. Here, to group by one column, pass the column name as a string.
Fill both blanks to create a dictionary with word lengths for words longer than 3 characters.
lengths = {word: [1] for word in words if len(word) [2] 3}The dictionary comprehension maps each word to its length using len(word). The condition filters words with length greater than 3 using the '>' operator.
Fill all three blanks to create a dictionary with uppercase keys, values, and filter condition.
result = [1]: [2] for k, v in data.items() if v [3] 0}
The dictionary comprehension uses k.upper() to make keys uppercase, keeps values as v, and filters items where v > 0.