Skip to content

Commit 5335b91

Browse files
author
chris
committed
CLN: replace %s syntax with .format in core/indexing.py
Progress toward issue pandas-dev#16130. Converted old string formatting to new string formatting in core/indexing.py.
1 parent 2bec750 commit 5335b91

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

pandas/core/indexing.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@ def _has_valid_tuple(self, key):
188188
if i >= self.obj.ndim:
189189
raise IndexingError('Too many indexers')
190190
if not self._has_valid_type(k, i):
191-
raise ValueError("Location based indexing can only have [%s] "
192-
"types" % self._valid_types)
191+
raise ValueError("Location based indexing can only have "
192+
"[{types}] types"
193+
.format(types=self._valid_types))
193194

194195
def _should_validate_iterable(self, axis=0):
195196
""" return a boolean whether this axes needs validation for a passed
@@ -263,11 +264,11 @@ def _has_valid_positional_setitem_indexer(self, indexer):
263264
pass
264265
elif is_integer(i):
265266
if i >= len(ax):
266-
raise IndexError("{0} cannot enlarge its target object"
267-
.format(self.name))
267+
raise IndexError("{name} cannot enlarge its target "
268+
"object".format(name=self.name))
268269
elif isinstance(i, dict):
269-
raise IndexError("{0} cannot enlarge its target object"
270-
.format(self.name))
270+
raise IndexError("{name} cannot enlarge its target object"
271+
.format(name=self.name))
271272

272273
return True
273274

@@ -1235,7 +1236,8 @@ def _convert_to_indexer(self, obj, axis=0, is_setter=False):
12351236

12361237
mask = check == -1
12371238
if mask.any():
1238-
raise KeyError('%s not in index' % objarr[mask])
1239+
raise KeyError('{mask} not in index'
1240+
.format(mask=objarr[mask]))
12391241

12401242
return _values_from_object(indexer)
12411243

@@ -1421,8 +1423,9 @@ def _has_valid_type(self, key, axis):
14211423
if (not is_iterator(key) and len(key) and
14221424
np.all(ax.get_indexer_for(key) < 0)):
14231425

1424-
raise KeyError("None of [%s] are in the [%s]" %
1425-
(key, self.obj._get_axis_name(axis)))
1426+
raise KeyError(u"None of [{key}] are in the [{axis}]"
1427+
.format(key=key,
1428+
axis=self.obj._get_axis_name(axis)))
14261429

14271430
return True
14281431

@@ -1432,8 +1435,9 @@ def error():
14321435
if isna(key):
14331436
raise TypeError("cannot use label indexing with a null "
14341437
"key")
1435-
raise KeyError("the label [%s] is not in the [%s]" %
1436-
(key, self.obj._get_axis_name(axis)))
1438+
raise KeyError(u"the label [{key}] is not in the [{axis}]"
1439+
.format(key=key,
1440+
axis=self.obj._get_axis_name(axis)))
14371441

14381442
try:
14391443
key = self._convert_scalar_indexer(key, axis)

0 commit comments

Comments
 (0)