Skip to content

pivot_table should fail if duplicate entries exist #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ukch opened this issue Nov 10, 2011 · 2 comments
Closed

pivot_table should fail if duplicate entries exist #354

ukch opened this issue Nov 10, 2011 · 2 comments

Comments

@ukch
Copy link

ukch commented Nov 10, 2011

This looks like #147, but I don't have permission to re-open that.

Consider the following situation:

In [3]: dt
Out[3]: 
   foo  bar  baz
0  1    2    3  
1  4    5    6  
2  1    2    4  

In [4]: pandas.pivot_table(dt, values="baz", rows=["foo"], cols=["bar"])
Out[4]: 
  bar  2    5  
foo            
1      3.5  NaN
4      NaN  6  

Notice the column for foo == 1 && bar == 2 shows a value of 3.5. Either this should be in the resulting table twice, or the command should fail with an error.

@ukch
Copy link
Author

ukch commented Nov 10, 2011

(Note: I am using pandas 0.5.0 with Python 2.6)

@wesm
Copy link
Member

wesm commented Nov 10, 2011

Pivot tables aggregate the values within a group, by default using mean but you can specify other functions. If you want to reshape, use the pivot instance method (df.pivot('foo', 'bar', 'baz')), which will throw an exception if there are duplicates.

@wesm wesm closed this as completed Nov 10, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants