@@ -208,6 +208,8 @@ class GroupBy(PandasObject):
208
208
Number of groups
209
209
"""
210
210
_apply_whitelist = _common_apply_whitelist
211
+ _internal_names = ['_cache' ]
212
+ _internal_names_set = set (_internal_names )
211
213
212
214
def __init__ (self , obj , keys = None , axis = 0 , level = None ,
213
215
grouper = None , exclusions = None , selection = None , as_index = True ,
@@ -288,10 +290,12 @@ def _local_dir(self):
288
290
return sorted (set (self .obj ._local_dir () + list (self ._apply_whitelist )))
289
291
290
292
def __getattr__ (self , attr ):
293
+ if attr in self ._internal_names_set :
294
+ return object .__getattribute__ (self , attr )
291
295
if attr in self .obj :
292
296
return self [attr ]
293
297
294
- if hasattr (self .obj , attr ) and attr != '_cache' :
298
+ if hasattr (self .obj , attr ):
295
299
return self ._make_wrapper (attr )
296
300
297
301
raise AttributeError ("%r object has no attribute %r" %
@@ -424,7 +428,8 @@ def f(g):
424
428
return self ._python_apply_general (f )
425
429
426
430
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 )
428
433
429
434
return self ._wrap_applied_output (keys , values ,
430
435
not_indexed_same = mutated )
0 commit comments