Skip to main contentSkip to solution

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

✅ Correct Option: 2

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question