Skip to content

Commit

Permalink
PERF pandas-dev#6570 patch by @jreback
Browse files Browse the repository at this point in the history
  • Loading branch information
hayd committed Mar 9, 2014
1 parent 33964db commit 0c10dad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ class GroupBy(PandasObject):
Number of groups
"""
_apply_whitelist = _common_apply_whitelist
_internal_names = ['_cache']
_internal_names_set = set(_internal_names)

def __init__(self, obj, keys=None, axis=0, level=None,
grouper=None, exclusions=None, selection=None, as_index=True,
Expand Down Expand Up @@ -288,10 +290,12 @@ def _local_dir(self):
return sorted(set(self.obj._local_dir() + list(self._apply_whitelist)))

def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]

if hasattr(self.obj, attr) and attr != '_cache':
if hasattr(self.obj, attr):
return self._make_wrapper(attr)

raise AttributeError("%r object has no attribute %r" %
Expand Down Expand Up @@ -424,7 +428,8 @@ def f(g):
return self._python_apply_general(f)

def _python_apply_general(self, f):
keys, values, mutated = self.grouper.apply(f, self._selected_obj, self.axis)
keys, values, mutated = self.grouper.apply(f, self._selected_obj,
self.axis)

return self._wrap_applied_output(keys, values,
not_indexed_same=mutated)
Expand Down

0 comments on commit 0c10dad

Please sign in to comment.