Skip to content

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

Closed
@cpbl

Description

@cpbl

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions