Unhelpful error message when groupby() called with a column that is duplicated · Issue #7511 · pandas-dev/pandas (original) (raw)
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"