Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: replace %s syntax with .format in core/indexing.py #17357

Merged
merged 1 commit into from
Aug 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down