Skip to main contentSkip to solution

The process of changing the structure of the DataFrame is known as reshaping. Which functions allow to do reshaping?

(A) pivot( )

(B) DataFrame_pivot( )

(C) PIVOT( )

(D) pivot_table( )

Solution

✅ Correct Option: 1

In pandas, reshaping is done with pivot() and pivot_table(). pivot() reshapes data by turning unique values of one column into new columns, and it needs unique index-column pairs. pivot_table() does the same but can also aggregate duplicate entries, for example with sum or mean.


(B) and (C): DataFrame_pivot() does not exist in pandas, and PIVOT() is not a function either, because Python names are case-sensitive and the correct name is lowercase pivot().

pivot() fails with duplicate index-column pairs, so use pivot_table() when duplicates need aggregating.

Keyboard Shortcuts

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