i[:5.5] does not have an obvious meaning.
i[:5] means the first 5 elements of the array (or list). i[:6] the first 6. What is it supposed to do with the 5.5? floor(5.5)? Ceiling? Return 5 and half elements? 5 elements plus a linear interpolation between the 5th and 6th?
Actually :5.5 works (in 1.11) but with a warning:
In [346]: np.arange(10)[:5]
Out[346]: array([0, 1, 2, 3, 4])
In [347]: np.arange(10)[:5.5]
/usr/local/bin/ipython3:1: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
#!/usr/bin/python3
Out[347]: array([0, 1, 2, 3, 4])
With your structured array, record indexing works the same way:
In [349]: i = np.array([(5.,1), (6.,2)], dtype=[('foo', 'f4'),('bar', 'i4')])
In [350]: i[:5]
It's ok to slice beyond the end - it just returns everything.
Out[350]:
array([(5.0, 1), (6.0, 2)],
dtype=[('foo', '<f4'), ('bar', '<i4')])
In [351]: i[:5.5]
/usr/local/bin/ipython3:1: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
#!/usr/bin/python3
Out[351]:
array([(5.0, 1), (6.0, 2)],
dtype=[('foo', '<f4'), ('bar', '<i4')])
================
Indexing in numpy is just a way of counting. There isn't an indexing or labeling list or array. That's something that pandas has added, but it isn't part of numpy. In your i array, fields do have names, e.g. i['foo']. It can look like column labeling, but it's dangerous to confuse structured fields with 2d columns.