The function used for reshaping the data is____.
The function used for reshaping the data is____.
Solution
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().
Related questions:
2025: 13 May Shift 2
2026: 24 May Shift 1