What does pivot_table( ) do in pandas that pivot( ) cannot?
What does pivot_table( ) do in pandas that pivot( ) cannot?
Solution
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.
Related questions:
2026: 29 May Shift 1
2025: 14 May Shift 1
2025: 15 May Shift 2
2025: 21 May Shift 1