Unhelpful error message when groupby() called with a column that is duplicated #7511

Closed
cpbl opened this Issue Jun 19, 2014 · 3 comments

Comments

Projects
None yet
3 participants

cpbl commented Jun 19, 2014

The following code:

import pandas as pd
p1 = {'name': 'willy', 'age': 10}
p2 = {'name': 'willy', 'age': 11}
p3 = {'name': 'zoe', 'age': 10}
df = pd.DataFrame([p1, p2, p3])
df = df[['name','name','age']]
df.groupby('name')

gives the following error:

TypeError: 'DataFrame' object is not callable

Instead, it should say "Cannot groupby a column which exists more than once"

Contributor

jreback commented Jun 19, 2014

that does seem unhelpful!

care to do a pull-request to fix (prob just catch the TypeError in core/groupby.pythen if its a duplicate raise maybe a ValueError) ?

jreback added this to the 0.15.0 milestone Jun 19, 2014

@jreback jreback modified the milestone: 0.15.0, 0.15.1 Sep 10, 2014

Contributor

jreback commented Sep 10, 2014

closed by #8210

jreback closed this Sep 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment