File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,20 @@ def test_column_contains_typeerror(self):
109109 except TypeError :
110110 pass
111111
112+ def test_tab_completion (self ):
113+ # DataFrame whose columns are identifiers shall have them in __dir__.
114+ df = pd .DataFrame ([list ('abcd' ), list ('efgh' )], columns = list ('ABCD' ))
115+ assert 'A' in dir (df )
116+ assert isinstance (df .__getitem__ ('A' ), pd .Series )
117+
118+ # DataFrame whose first-level columns are identifiers shall have
119+ # them in __dir__.
120+ df = pd .DataFrame (
121+ [list ('abcd' ), list ('efgh' )],
122+ columns = pd .MultiIndex .from_tuples (list (zip ('ABCD' , 'EFGH' ))))
123+ assert 'A' in dir (df )
124+ assert isinstance (df .__getitem__ ('A' ), pd .DataFrame )
125+
112126 def test_not_hashable (self ):
113127 df = pd .DataFrame ([1 ])
114128 pytest .raises (TypeError , hash , df )
You can’t perform that action at this time.
0 commit comments