Arrange the following process with respect to GROUP BY functions:
(A) Split the data into groups by creating a GROUP BY object from the original DataFrame.
(B) Combine the results to form a new DataFrame.
(C) Print the results.
(D) Apply the required function.
Arrange the following process with respect to GROUP BY functions:
(A) Split the data into groups by creating a GROUP BY object from the original DataFrame.
(B) Combine the results to form a new DataFrame.
(C) Print the results.
(D) Apply the required function.
Solution
GROUP BY in pandas follows the split-apply-combine pattern, and the output is printed only after the new DataFrame exists.
(A) Split the data into groups by creating a GROUP BY object from the original DataFrame
(D) Apply the required function (such as sum, mean or count) to each group
(B) Combine the results to form a new DataFrame
(C) Print the results
Option 1: combines before applying the function, but there is nothing to combine until the function has been applied to each group.
Related questions:
2026: 29 May Shift 2
2026: 29 May Shift 1
2025: 30 May Shift 2