-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
Error ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandasNeeds InfoClarification about behavior needed to assess issueClarification about behavior needed to assess issueReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, Explode
Description
Pandas version checks
- I have checked that the issue still exists on the latest versions of the docs on
main
hereTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Location of the documentation
doc/source/user_guide/reshaping.rst
Documentation problem
the table given as an example for pivot() is wrong and cant be used. it would return "error duplicate index" as there are duplicate values in the column given for "index" parameter.

Suggested fix for documentation
The "foo" column must contain unique values
Metadata
Metadata
Assignees
Labels
Error ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandasNeeds InfoClarification about behavior needed to assess issueClarification about behavior needed to assess issueReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, Explode
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
goutam-kul commentedon Mar 5, 2025
@mheskett It will not throw
ValueError: Index contains duplicate entries, cannot reshape
, because theindex
(fool
) andcolumns
(bar
) have unique combinations:Output:
What happens if I introduce a non-unique combination? yes it will throw duplicate index error. E.g:
Output:
ValueError: Index contains duplicate entries, cannot reshape
While you can use
pivot_table
method when your have duplicate values in index and columnOutput:
Hope this helps!
mheskett commentedon Mar 5, 2025
thank you. so in that case, the ValueError message is misleading. I can raise a separate issue about that. it should read "must contain unique combinations of index and column"
rhshadrach commentedon Mar 5, 2025
We can rework this issue instead. Why do you feel the ValueError is misleading?