Skip to content

Commit f4c763f

Browse files
author
Martin Journois
committed
TST: Add test on DataFrame columns auto-completion
1 parent 41704e2 commit f4c763f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/frame/test_api.py

+14
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,20 @@ def test_column_contains_typeerror(self):
128128
except TypeError:
129129
pass
130130

131+
def test_tab_completion(self):
132+
# DataFrame whose columns are identifiers shall have them in __dir__.
133+
df = pd.DataFrame([list('abcd'), list('efgh')], columns=list('ABCD'))
134+
assert 'A' in dir(df)
135+
assert isinstance(df.__getitem__('A'), pd.Series)
136+
137+
# DataFrame whose first-level columns are identifiers shall have
138+
# them in __dir__.
139+
df = pd.DataFrame(
140+
[list('abcd'), list('efgh')],
141+
columns=pd.MultiIndex.from_tuples(list(zip('ABCD', 'EFGH'))))
142+
assert 'A' in dir(df)
143+
assert isinstance(df.__getitem__('A'), pd.DataFrame)
144+
131145
def test_not_hashable(self):
132146
df = self.klass([1])
133147
pytest.raises(TypeError, hash, df)

0 commit comments

Comments
 (0)