1919from pandas .util ._decorators import (Appender , cache_readonly ,
2020 deprecate_kwarg , Substitution )
2121from pandas .core .common import AbstractMethodError
22+ from pandas .core .accessor import DirNamesMixin
2223
2324_shared_docs = dict ()
2425_indexops_doc_kwargs = dict (klass = 'IndexOpsMixin' , inplace = '' ,
@@ -73,7 +74,7 @@ def __repr__(self):
7374 return str (self )
7475
7576
76- class PandasObject (StringMixin ):
77+ class PandasObject (StringMixin , DirNamesMixin ):
7778
7879 """baseclass for various pandas objects"""
7980
@@ -92,23 +93,6 @@ def __unicode__(self):
9293 # Should be overwritten by base classes
9394 return object .__repr__ (self )
9495
95- def _dir_additions (self ):
96- """ add addtional __dir__ for this object """
97- return set ()
98-
99- def _dir_deletions (self ):
100- """ delete unwanted __dir__ for this object """
101- return set ()
102-
103- def __dir__ (self ):
104- """
105- Provide method name lookup and completion
106- Only provide 'public' methods
107- """
108- rv = set (dir (type (self )))
109- rv = (rv - self ._dir_deletions ()) | self ._dir_additions ()
110- return sorted (rv )
111-
11296 def _reset_cache (self , key = None ):
11397 """
11498 Reset cached properties. If ``key`` is passed, only clears that key.
@@ -141,7 +125,7 @@ class NoNewAttributesMixin(object):
141125
142126 Prevents additional attributes via xxx.attribute = "something" after a
143127 call to `self.__freeze()`. Mainly used to prevent the user from using
144- wrong attrirbutes on a accessor (`Series.cat/.str/.dt`).
128+ wrong attributes on a accessor (`Series.cat/.str/.dt`).
145129
146130 If you really want to add a new attribute at a later time, you need to use
147131 `object.__setattr__(self, key, value)`.
0 commit comments