@@ -208,6 +208,8 @@ class GroupBy(PandasObject):
208208 Number of groups
209209 """
210210 _apply_whitelist = _common_apply_whitelist
211+ _internal_names = ['_cache' ]
212+ _internal_names_set = set (_internal_names )
211213
212214 def __init__ (self , obj , keys = None , axis = 0 , level = None ,
213215 grouper = None , exclusions = None , selection = None , as_index = True ,
@@ -288,10 +290,12 @@ def _local_dir(self):
288290 return sorted (set (self .obj ._local_dir () + list (self ._apply_whitelist )))
289291
290292 def __getattr__ (self , attr ):
293+ if attr in self ._internal_names_set :
294+ return object .__getattribute__ (self , attr )
291295 if attr in self .obj :
292296 return self [attr ]
293297
294- if hasattr (self .obj , attr ) and attr != '_cache' :
298+ if hasattr (self .obj , attr ):
295299 return self ._make_wrapper (attr )
296300
297301 raise AttributeError ("%r object has no attribute %r" %
@@ -424,7 +428,8 @@ def f(g):
424428 return self ._python_apply_general (f )
425429
426430 def _python_apply_general (self , f ):
427- keys , values , mutated = self .grouper .apply (f , self ._selected_obj , self .axis )
431+ keys , values , mutated = self .grouper .apply (f , self ._selected_obj ,
432+ self .axis )
428433
429434 return self ._wrap_applied_output (keys , values ,
430435 not_indexed_same = mutated )
0 commit comments