Skip to content

Commit 4dbf456

Browse files
add a test to check zero index array do not error
closes #21946
1 parent e31b4f4 commit 4dbf456

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/indexing/test_indexing.py

+8
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,14 @@ def test_no_reference_cycle(self):
855855
del df
856856
assert wr() is None
857857

858+
def test_no_error_for_zero_index(self):
859+
# GH-21946
860+
df = DataFrame([[1, 2], [3, 4]], columns=['a', 'b'])
861+
ar = np.array(0)
862+
try:
863+
assert df.iloc[ar].all() == df.iloc[0].all()
864+
except TypeError:
865+
pytest.fail("Unexpected TypeError, should be first element of array.")
858866

859867
class TestSeriesNoneCoercion(object):
860868
EXPECTED_RESULTS = [

0 commit comments

Comments
 (0)