📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    In pandas, what does df.groupby('A').agg({'B': 'sum',

    'C': 'mean'}) return?
    A A DataFrame with aggregated columns B and C by groups of A. Correct Answer Incorrect Answer
    B A Series indexed by A with tuple values. Correct Answer Incorrect Answer
    C Raises an error due to mixed aggregations. Correct Answer Incorrect Answer
    D A list of DataFrames. Correct Answer Incorrect Answer
    E A pivot table that loses grouping index. Correct Answer Incorrect Answer

    Solution

    .groupby(...).agg({...}) returns a DataFrame indexed by group keys with specified aggregated columns.

    Practice Next
    ask-question