__________ and _________ are the two functions used for changing the structure of a dataframe.
__________ and _________ are the two functions used for changing the structure of a dataframe.
Solution
pivot() reshapes a dataframe by turning the unique values of one column into new column headers, so rows become columns. pivot_table() does the same but also aggregates duplicate entries (for example with a mean or sum). Both change the structure (shape) of the dataframe.
Option 2: reset_index() and set_index() only change which column acts as the index. They do not reshape the data.
Option 3: pandas has groupby(), not group_by(). Also, transpose() only swaps rows and columns, while groupby() groups data for aggregation.
Option 4: aggregate() summarises data and sort_values() only reorders rows, so neither restructures the dataframe.
Related questions:
2025: 13 May Shift 2
2026: 31 May Shift 1