pydata/pandas — pull request #8210 by bthyreau (2014-09-08 02:41:35+00:00)
Title: BUG: Fix groupby duplicate column

Though having duplicated column names in a dataframe is never a good idea, it may happen, and that shouldn't confuse groupby() with a meaningless message. Currently
```python
>>> obj=pd.DataFrame(columns=["A","B","A", "C"], data=[range(4), range(2,6), range(0, 8, 2)])
>>> obj.groupby("A").mean()
Traceback (most recent call last):
File "", line 1, in
File "pandas/core/generic.py", line 2846, in groupby
sort=sort, group_keys=group_keys, squeeze=squeeze)
File "pandas/core/groupby.py", line 1173, in groupby
return klass(obj, by, **kwds)
File "pandas/core/groupby.py", line 390, in __init__
level=level, sort=sort)
File "pandas/core/groupby.py", line 2086, in _get_grouper
ping = Grouping(group_axis, gpr, obj=obj, name=name, level=level, sort=sort)
File "pandas/core/groupby.py", line 1925, in __init__
self.grouper = self.index.map(self.grouper)
File "pandas/core/index.py", line 1524, in map
return self._arrmap(self.values, mapper)
File "generated.pyx", line 2203, in pandas.algos.arrmap_int64 (pandas/algos.c:72274)
TypeError: 'DataFrame' object is not callable
```
This patch fixes that.
```python
>>> obj.groupby("A").mean()
B C
A A
0 2 1 3
4 2 6
2 4 3 5
```
Thanks.