Skip to main contentSkip to solution

__________ and _________ are the two functions used for changing the structure of a dataframe.

Solution

✅ Correct Option: 1

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.

Keyboard Shortcuts

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