I have the following list
import numpy as np
Y = [np.array([[1, 4, 7],
[2, 5, 8]]),
np.array([[10, 14, 18],
[11, 15, 19],
[12, 16, 20],
[13, 17, 21]]),
np.array([[22, 26, 31],
[24, 28, 33],
[26, 30, 35]])]
I want to loop through and print the columns inside of all the arrays in Y.
I don't know how to access the columns of Y. Running Y[:,0] for example, does not give me
[[1]
[2]]
Instead, it gives me the following error
TypeError: list indices must be integers or slices, not tuple
I want to print all columns of all the arrays in Y, not just the first column of the first array.
np.concatenate(Y)with your current data? You can, of course, donp.concatenate(Y)[:,0], but if would make more sense to start with a structure that supports the thing you want to accomplish.Yis a list. It doesn't have columns. The array elements are 2d, and have columns.You have to iterate on the list.