Skip to main contentSkip to solution

What does pivot_table( ) do in pandas that pivot( ) cannot?

Solution

✅ Correct Option: 1

pivot() only reshapes data. If the index/column pair has duplicate entries, it raises a ValueError. pivot_table() handles duplicates by applying an aggregation function (default is mean, set with aggfunc, e.g. sum, count, max) to the values in those rows.


Option 2: this is the reverse. pivot() is the one that cannot reshape duplicate data.

Option 3: merging dataframes is done by merge(), join() or concat(), not pivot_table().

Option 4: NaN is not converted to zero by default. It happens only if you pass fill_value=0, and fillna() does the same job elsewhere.

Keyboard Shortcuts

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