diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 6b9ad5cd2d93b7..b7a51afcedabfe 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -188,8 +188,9 @@ def _has_valid_tuple(self, key): if i >= self.obj.ndim: raise IndexingError('Too many indexers') if not self._has_valid_type(k, i): - raise ValueError("Location based indexing can only have [%s] " - "types" % self._valid_types) + raise ValueError("Location based indexing can only have " + "[{types}] types" + .format(types=self._valid_types)) def _should_validate_iterable(self, axis=0): """ return a boolean whether this axes needs validation for a passed @@ -263,11 +264,11 @@ def _has_valid_positional_setitem_indexer(self, indexer): pass elif is_integer(i): if i >= len(ax): - raise IndexError("{0} cannot enlarge its target object" - .format(self.name)) + raise IndexError("{name} cannot enlarge its target " + "object".format(name=self.name)) elif isinstance(i, dict): - raise IndexError("{0} cannot enlarge its target object" - .format(self.name)) + raise IndexError("{name} cannot enlarge its target object" + .format(name=self.name)) return True @@ -1235,7 +1236,8 @@ def _convert_to_indexer(self, obj, axis=0, is_setter=False): mask = check == -1 if mask.any(): - raise KeyError('%s not in index' % objarr[mask]) + raise KeyError('{mask} not in index' + .format(mask=objarr[mask])) return _values_from_object(indexer) @@ -1421,8 +1423,9 @@ def _has_valid_type(self, key, axis): if (not is_iterator(key) and len(key) and np.all(ax.get_indexer_for(key) < 0)): - raise KeyError("None of [%s] are in the [%s]" % - (key, self.obj._get_axis_name(axis))) + raise KeyError(u"None of [{key}] are in the [{axis}]" + .format(key=key, + axis=self.obj._get_axis_name(axis))) return True @@ -1432,8 +1435,9 @@ def error(): if isna(key): raise TypeError("cannot use label indexing with a null " "key") - raise KeyError("the label [%s] is not in the [%s]" % - (key, self.obj._get_axis_name(axis))) + raise KeyError(u"the label [{key}] is not in the [{axis}]" + .format(key=key, + axis=self.obj._get_axis_name(axis))) try: key = self._convert_scalar_indexer(key, axis)