19
19
from pandas .util ._decorators import (Appender , cache_readonly ,
20
20
deprecate_kwarg , Substitution )
21
21
from pandas .core .common import AbstractMethodError
22
+ from pandas .core .accessor import DirNamesMixin
22
23
23
24
_shared_docs = dict ()
24
25
_indexops_doc_kwargs = dict (klass = 'IndexOpsMixin' , inplace = '' ,
@@ -73,7 +74,7 @@ def __repr__(self):
73
74
return str (self )
74
75
75
76
76
- class PandasObject (StringMixin ):
77
+ class PandasObject (StringMixin , DirNamesMixin ):
77
78
78
79
"""baseclass for various pandas objects"""
79
80
@@ -92,23 +93,6 @@ def __unicode__(self):
92
93
# Should be overwritten by base classes
93
94
return object .__repr__ (self )
94
95
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
-
112
96
def _reset_cache (self , key = None ):
113
97
"""
114
98
Reset cached properties. If ``key`` is passed, only clears that key.
@@ -141,7 +125,7 @@ class NoNewAttributesMixin(object):
141
125
142
126
Prevents additional attributes via xxx.attribute = "something" after a
143
127
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`).
145
129
146
130
If you really want to add a new attribute at a later time, you need to use
147
131
`object.__setattr__(self, key, value)`.
0 commit comments