Arrange the steps to split the data in to groups using the GROUP BY() based on some criteria:
A. Apply the required function.
B. Print the new DataFrame.
C. Combine the results to form a new DataFrame.
D. Split the data into groups by creating a GROUP BY object from the original DataFrame.
Arrange the steps to split the data in to groups using the GROUP BY() based on some criteria:
A. Apply the required function.
B. Print the new DataFrame.
C. Combine the results to form a new DataFrame.
D. Split the data into groups by creating a GROUP BY object from the original DataFrame.
Solution
GROUP BY follows the split-apply-combine pattern, and printing comes last.
D. Split the data into groups by creating a GROUP BY object from the original DataFrame.
A. Apply the required function (such as sum, mean or count) to each group.
C. Combine the results to form a new DataFrame.
B. Print the new DataFrame.
Option 2: combining before applying the function is wrong, because the combined DataFrame is made from the results of the function.
Related questions:
2026: 24 May Shift 1
2026: 31 May Shift 1