|
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:
|
@@ -1326,7 +1331,7 @@ def filter(self, items=None, like=None, regex=None, axis=None):
|
1326 | 1331 | if items is not None:
|
1327 | 1332 | return self.reindex(**{axis_name: [r for r in items if r in axis_values]})
|
1328 | 1333 | elif like:
|
1329 |
| - matchf = lambda x: (like in x if isinstance(x, compat.string_types) |
| 1334 | + matchf = lambda x: (like in x if isinstance(x, string_types) |
1330 | 1335 | else like in str(x))
|
1331 | 1336 | return self.select(matchf, axis=axis_name)
|
1332 | 1337 | elif regex:
|
@@ -2616,7 +2621,7 @@ def tshift(self, periods=1, freq=None, axis=0, **kwds):
|
2616 | 2621 |
|
2617 | 2622 | offset = _resolve_offset(freq, kwds)
|
2618 | 2623 |
|
2619 |
| - if isinstance(offset, compat.string_types): |
| 2624 | + if isinstance(offset, string_types): |
2620 | 2625 | offset = datetools.to_offset(offset)
|
2621 | 2626 |
|
2622 | 2627 | block_axis = self._get_block_manager_axis(axis)
|
|
0 commit comments