Skip to main contentSkip to solution

The function used for reshaping the data is____.

Solution

✅ Correct Option: 1

pivot() reshapes a DataFrame. It takes the unique values of one column as the new index, another column's values as the new columns, and fills the table with a third column's values. This turns long-format data into wide-format data.


Option 2: reset_index() only moves the index back into a column and restores the default 0, 1, 2... index. It does not change the layout of the data.

Option 3: isnull() flags missing values with True or False. It does not reshape.

Option 4: dropna() removes rows or columns that contain missing values, which changes the size of the data but not its structure.

Other reshaping functions in pandas are melt(), stack(), unstack() and pivot_table().

Keyboard Shortcuts

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