What does pd.pivot_table primarily produce in pandas?
Correct answer
D. A cross-tabulation with aggregated values at row and column intersections
16 views
D. A cross-tabulation with aggregated values at row and column intersections
16 views
pivot_table groups by one field for rows and another for columns, then aggregates the values at each intersection, defaulting to the mean. It is essentially groupby plus a reshape, and the inverse operation that melts a wide table back into long form is melt. Passing aggfunc="sum" or a list of functions controls the summary, and margins=True adds row and column totals.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is D? Ask here and get an explanation.