We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8320c7f commit a87f059Copy full SHA for a87f059
pandas/tests/indexing/test_loc.py
@@ -1081,3 +1081,21 @@ def test_series_loc_getitem_label_list_missing_values():
1081
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
1082
result = s.loc[key]
1083
tm.assert_series_equal(result, expected)
1084
+
1085
1086
+@pytest.mark.parametrize(
1087
+ "columns, column_key, expected_columns, check_column_type",
1088
+ [
1089
+ ([2011, 2012, 2013], [2011, 2012], [0, 1], True),
1090
+ ([2011, 2012, "All"], [2011, 2012], [0, 1], False),
1091
+ ([2011, 2012, "All"], [2011, "All"], [0, 2], True),
1092
+ ],
1093
+)
1094
+def test_loc_getitem_label_list_integer_labels(
1095
+ columns, column_key, expected_columns, check_column_type
1096
+):
1097
+ # gh-14836
1098
+ df = DataFrame(np.random.rand(3, 3), columns=columns, index=list("ABC"))
1099
+ expected = df.iloc[:, expected_columns]
1100
+ result = df.loc[["A", "B", "C"], column_key]
1101
+ tm.assert_frame_equal(result, expected, check_column_type=check_column_type)
0 commit comments