Skip to main contentSkip to solution

Arrange the following statements based on the sequence of execution in the context of Group By operations.

(A) Split the data

(B) Display the output

(C) Combine the results

(D) Apply the function

Solution

✅ Correct Option: 1

Group By in pandas follows the split-apply-combine pattern. The data is first split into groups by key (A), then a function such as sum or mean is applied to each group (D), the per-group results are combined into one structure (C), and finally the output is displayed (B).

The order is (A)→(D)→(C)→(B)(A) \to (D) \to (C) \to (B).


Options 2 and 3: display cannot come first, because there is no output until the grouping, function and combine are done.

Option 3 also swaps apply and combine. The function must run on each group before the results can be combined.

Keyboard Shortcuts

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