I have a list e of 2d arrays, which I want to flatten to get a list of 1d arrays
When I use on one element:
e[0].flatten() it works. But when I want to transform every element with:
enew = [e[i].flatten() for i in e] the failure gets raised:
IndexError: arrays used as indices must be of integer (or boolean) type
eusing elements ineas indices. So when you calle[i]you are using an array (i) as an index to a list (e). As the error message suggests, only integer and boolean arrays are acceptable as indices for lists. What you want is to callflatten()on each item individually (see the answer by @YTTY).