Complete the code to group the DataFrame by the 'Category' column.
grouped = df.groupby([1])The groupby function groups data based on the values in the specified column. Here, grouping by 'Category' means data will be summarized for each category.
Complete the code to calculate the sum of values for each category.
summary = df.groupby('Category').[1]()
mean() which calculates average instead of sum.count() which counts rows, not sums values.The sum() function adds up all values in each group, giving the total per category.
Fix the error in the code to group by 'Category' and get the average value.
result = df.[1]('Category').mean()
The correct method to group data in pandas is groupby(). Other options are invalid and cause errors.
Fill both blanks to create a dictionary comprehension that maps each word to its length only if the length is greater than 3.
lengths = {word: [1] for word in words if [2]The dictionary comprehension maps each word to its length using len(word). The condition len(word) > 3 filters words longer than 3 characters.
Fill all three blanks to create a dictionary comprehension that maps uppercase keys to values, including only items where value is positive.
result = [1]: [2] for [3], v in data.items() if v > 0}
The comprehension uses k.upper() as keys, v as values, and iterates over k, v pairs from data.items(). It filters to keep only positive values.