Q:

NumPy slicing gives IndexError: too many indices for array

I have a sample numpy array read from a file like this:
import numpy as np
data = np.array([(b'M', 119.,  76.), (b'M', 114.,  73.), (b'F', 124.,  79.)],
dtype=[('gender', 'S1'), ('bps', '<f8'), ('bpd', '<f8')])

How to get the first column called gender?
I tried:
gender = data[:,0] # fails
gender = [i[0] for i in data] # pass

Is there easier way to get the first column without list comprehension?
Can we unpack 3 columns like g,b,p=*data?

A:

First of all, your data doesn't have a column. It is just a 1d array.
data.shape
(3, )

So the slicing will raise IndexError as you passed 2d indices.
Try:
list(zip(*data))[0]
# (b'M', b'M', b'F')

