|
16 | 16 | import pandas.core.common as com
|
17 | 17 | import pandas.core.datetools as datetools
|
18 | 18 | from pandas import compat, _np_version_under1p7
|
19 |
| -from pandas.compat import map, zip, lrange |
| 19 | +from pandas.compat import map, zip, lrange, string_types, isidentifier |
20 | 20 | from pandas.core.common import (isnull, notnull, is_list_like,
|
21 | 21 | _values_from_object,
|
22 | 22 | _infer_dtype_from_scalar, _maybe_promote,
|
@@ -109,6 +109,11 @@ def __unicode__(self):
|
109 | 109 | prepr = '[%s]' % ','.join(map(com.pprint_thing, self))
|
110 | 110 | return '%s(%s)' % (self.__class__.__name__, prepr)
|
111 | 111 |
|
| 112 | + def _local_dir(self): |
| 113 | + """ add the string-like attributes from the info_axis """ |
| 114 | + return [c for c in self._info_axis |
| 115 | + if isinstance(c, string_types) and isidentifier(c) ] |
| 116 | + |
112 | 117 | @property
|
113 | 118 | def _constructor_sliced(self):
|
114 | 119 | raise NotImplementedError
|
@@ -252,7 +257,7 @@ def _get_axis_number(self, axis):
|
252 | 257 |
|
253 | 258 | def _get_axis_name(self, axis):
|
254 | 259 | axis = self._AXIS_ALIASES.get(axis, axis)
|
255 |
| - if isinstance(axis, compat.string_types): |
| 260 | + if isinstance(axis, string_types): |
256 | 261 | if axis in self._AXIS_NUMBERS:
|
257 | 262 | return axis
|
258 | 263 | else:
|
@@ -1311,7 +1316,7 @@ def filter(self, items=None, like=None, regex=None, axis=None):
|
1311 | 1316 | if items is not None:
|
1312 | 1317 | return self.reindex(**{axis_name: [r for r in items if r in axis_values]})
|
1313 | 1318 | elif like:
|
1314 |
| - matchf = lambda x: (like in x if isinstance(x, compat.string_types) |
| 1319 | + matchf = lambda x: (like in x if isinstance(x, string_types) |
1315 | 1320 | else like in str(x))
|
1316 | 1321 | return self.select(matchf, axis=axis_name)
|
1317 | 1322 | elif regex:
|
@@ -2601,7 +2606,7 @@ def tshift(self, periods=1, freq=None, axis=0, **kwds):
|
2601 | 2606 |
|
2602 | 2607 | offset = _resolve_offset(freq, kwds)
|
2603 | 2608 |
|
2604 |
| - if isinstance(offset, compat.string_types): |
| 2609 | + if isinstance(offset, string_types): |
2605 | 2610 | offset = datetools.to_offset(offset)
|
2606 | 2611 |
|
2607 | 2612 | block_axis = self._get_block_manager_axis(axis)
|
|
0 commit comments