11
When I create a one dimensional array in numpy and use a string (containing digits) to index it, I get an error as expected:
>>> import numpy as np
>>> a = np.arange(15)
>>> a['10']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: field named 10 not found.
However, when I create a two dimensional array and use two strings for indexing, it gives no error and returns the element as if the strings are converted to integers first
>>> b = np.arange(15).reshape(3,5)
>>> b
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]])
>>> b[1, 2]
7
>>> b['1', '2']
7
What's going on? Why don't I get an error in the two dimensional case?