Skip to content

Commit 9cba8f3

Browse files
author
Martin Journois
committed
ENH: _dir_additions returns also the first level of a MultiIndex
1 parent 1eedcf6 commit 9cba8f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/core/generic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ def __unicode__(self):
194194
return '%s(%s)' % (self.__class__.__name__, prepr)
195195

196196
def _dir_additions(self):
197-
""" add the string-like attributes from the info_axis """
198-
additions = set([c for c in self._info_axis
197+
""" add the string-like attributes from the info_axis.
198+
If info_axis is a MultiIndex, it's first level values are used.
199+
"""
200+
additions = set([c for c in self._info_axis.get_level_values(0)
199201
if isinstance(c, string_types) and isidentifier(c)])
200202
return super(NDFrame, self)._dir_additions().union(additions)
201203

0 commit comments

Comments
 (0)