From 9c970d8b783bbf193caf247c50e66729ff44e456 Mon Sep 17 00:00:00 2001 From: Ben Nelson Date: Sat, 23 Mar 2019 19:28:52 -0600 Subject: [PATCH] add a test to check zero index array do not error closes #21946 --- pandas/tests/indexing/test_indexing.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/tests/indexing/test_indexing.py b/pandas/tests/indexing/test_indexing.py index e6ee35572c252..3f93b9798c594 100644 --- a/pandas/tests/indexing/test_indexing.py +++ b/pandas/tests/indexing/test_indexing.py @@ -855,6 +855,14 @@ def test_no_reference_cycle(self): del df assert wr() is None + def test_no_error_for_zero_index(self): + # GH-21946 + df = DataFrame([[1, 2], [3, 4]], columns=['a', 'b']) + ar = np.array(0) + try: + tm.assert_frame_equal(df.iloc[ar], df.iloc[0]) + except TypeError: + pytest.fail("Unexpected TypeError, should be first element of array.") class TestSeriesNoneCoercion(object): EXPECTED_RESULTS = [