I've got a .csv file that I'm trying to load into a numpy array as a column vector. When using
temp = np.genfromtxt(location, delimiter=',')
the data is a numpy array where the entries are represented as follows:
[ 0. ... 0. 1. 0. ... 0.], [ 0. ... 1. 0. 0. ... 0.]
whereas, I would like something like this:
[array([[0],
[0],
[0],
...
[0],
[1],
[0],
...
[0],
[0]]), array([[0],
[0],
[0],
...
[0],
[1],
[0],
...)]
I'm able to accomplish this using
my_data = []
for i in range(len(temp)):
foo = np.array([temp[i]]).T
my_data.append(foo)
But am wondering if there is a more efficient way of achieving the required result.
temp[:, :, None].tolist()