wesm/pandas — Issue #697: GroupBy by level bug
Author: wesm
Created: 2012-01-26 23:13:17+00:00
State: open
Labels: Bug, prio-high

reported by user, almost certainly a corner case introduced by the list changes recently

```
In [11]: df
Out[11]:
a b c d
one two three
foo bar baz -0.2732 1 -0.2732 1

In [12]: df.groupby(level='three')

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/wesm/code/pandas/ in ()
----> 1 df.groupby(level='three')

/home/wesm/code/pandas/pandas/core/generic.pyc in groupby(self, by, axis, level, as_index, sort)
120 from pandas.core.groupby import groupby
121 return groupby(self, by, axis=axis, level=level, as_index=as_index,
--> 122 sort=sort)
123
124 def select(self, crit, axis=0):

/home/wesm/code/pandas/pandas/core/groupby.pyc in groupby(obj, by, **kwds)
520 raise TypeError('invalid type: %s' % type(obj))
521
--> 522 return klass(obj, by, **kwds)
523
524 def _get_axes(group):

/home/wesm/code/pandas/pandas/core/groupby.pyc in __init__(self, obj, grouper, axis, level, groupings, exclusions, column, as_index, sort)
112 if groupings is None:
113 groupings, exclusions = _get_groupings(obj, grouper, axis=axis,
--> 114 level=level, sort=sort)
115
116 self.groupings = groupings

/home/wesm/code/pandas/pandas/core/groupby.pyc in _get_groupings(obj, grouper, axis, level, sort)
720 name = gpr
721 gpr = obj[gpr]
--> 722 ping = Grouping(group_axis, gpr, name=name, level=level, sort=sort)
723 if ping.name is None:
724 ping.name = 'key_%d' % i

/home/wesm/code/pandas/pandas/core/groupby.pyc in __init__(self, index, grouper, name, level, sort)
589 level_values = index.levels[level].take(inds)
590 if grouper is not None:
--> 591 self.grouper = level_values.map(self.grouper)
592 else:
593 self._was_factor = True

/home/wesm/code/pandas/pandas/core/index.pyc in map(self, mapper)
580
581 def map(self, mapper):
--> 582 return self._arrmap(self.values, mapper)
583
584 def _get_method(self, method):

/home/wesm/code/pandas/pandas/_tseries.so in pandas._tseries.arrmap_object (pandas/src/tseries.c:41721)()

TypeError: 'numpy.ndarray' object is not callable
```