Using the example given here:
dt = np.dtype([('name', np.unicode_, 16), ('grades', np.float64, (2,))])
x = np.array([('Sarah', (8.0, 7.0)), ('John', (6.0, 7.0))], dtype=dt)
How can I access only the grades at say position 0 in the 'grades' array?
Because of the ambiguitiy of how I can access the grades of a specific person, i.e. because I can either write
>>> x['grades'][0]
>>> [8.0 7.0]
or
>>> x[0]['grades']
>>> [8.0 7.0]
which will both give the same result, I don't see any way for how I would be able to only access the grade at position 0, but for all the persons. Is there a way?
I cannot write
>>> x[0]['grades'][0]
>>> 8.0
or some combination like this
>>> x[:]['grades'][0]
>>> x[0]['grades'][:]
On the same note: Why is the shape of the 'grades' field declared as '(2,)', while '(2)', '[2,]', '[2]' and '2' all seem to give the same results?