Skip to content

Commit 6388d93

Browse files
committed
Reverse indexing order
1 parent 8677f0d commit 6388d93

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

pandas/core/indexing.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,11 +1068,7 @@ def _getitem_lowerdim(self, tup: tuple):
10681068

10691069
# Reverse tuple so that we are indexing along columns before rows
10701070
# and avoid unintended dtype inference. # GH60600
1071-
if any(isinstance(ax, MultiIndex) for ax in self.obj.axes):
1072-
enum = enumerate(tup)
1073-
else:
1074-
enum = zip(range(len(tup) - 1, -1, -1), reversed(tup))
1075-
for i, key in enum:
1071+
for i, key in zip(range(len(tup) - 1, -1, -1), reversed(tup)):
10761072
if is_label_like(key) or is_list_like(key):
10771073
# We don't need to check for tuples here because those are
10781074
# caught by the _is_nested_tuple_indexer check above.

pandas/tests/indexing/multiindex/test_loc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def test_missing_keys_raises_keyerror(self):
757757
df = DataFrame(np.arange(12).reshape(4, 3), columns=["A", "B", "C"])
758758
df2 = df.set_index(["A", "B"])
759759

760-
with pytest.raises(KeyError, match="1"):
760+
with pytest.raises(KeyError, match="6"):
761761
df2.loc[(1, 6)]
762762

763763
def test_missing_key_raises_keyerror2(self):

pandas/tests/indexing/test_loc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def test_loc_to_fail(self):
449449

450450
msg = (
451451
rf"\"None of \[Index\(\[1, 2\], dtype='{np.dtype(int)}'\)\] are "
452-
r"in the \[index\]\""
452+
r"in the \[columns\]\""
453453
)
454454
with pytest.raises(KeyError, match=msg):
455455
df.loc[[1, 2], [1, 2]]

0 commit comments

Comments
 (0)