Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8144665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:26:45+00:00 2026-06-06T13:26:45+00:00

On Pandas documentation of the pivot method, we have: Examples ——– >>> df foo

  • 0

On Pandas documentation of the pivot method, we have:

Examples
--------
>>> df
    foo   bar  baz
0   one   A    1.
1   one   B    2.
2   one   C    3.
3   two   A    4.
4   two   B    5.
5   two   C    6.

>>> df.pivot('foo', 'bar', 'baz')
     A   B   C
one  1   2   3
two  4   5   6

My DataFrame is structured like this:

   name   id     x
----------------------
0  john   1      0
1  john   2      0
2  mike   1      1
3  mike   2      0

And I want something like this:

      1    2   # (this is the id as columns)
----------------------
mike  0    0   # (and this is the 'x' as values)
john  1    0

But when I run the pivot method, it is saying:

*** ReshapeError: Index contains duplicate entries, cannot reshape

Which doesn’t makes sense, even in example there are repeated entries on the foo column. I’m using the name column as the index of the pivot, the first argument of the pivot method call.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:26:48+00:00Added an answer on June 6, 2026 at 1:26 pm

    Works fine for me? Can you post the exact pivot method call you’re using?

    In [4]: df.pivot('name', 'id', 'x')
    Out[4]: 
    id    1  2
    name      
    john  0  0
    mike  1  0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pandas DataFrame and I want to plot a bar chart that
I have a pandas DataFrame with a date column. It is not an index.
I have the data below saved as a pandas dataframe . With this data,
I have the following Pandas Dataframe with a MultiIndex(Z,A): H1 H2 Z A 0
I have a pandas DataFrame that has multiple columns in it: Index: 239897 entries,
Recently I'm doing some work with two Series in pandas: The first Series contains
I have a pandas panel of investment pricing data to which I want to
This is Pandas dataframe I want to convert 1D data into 2D array form
I'm having trouble writing the entries of a pandas dataframe to a stringbuffer. It's
If I use the following methodology to construct a pandas.DataFrame , I get an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.