I have a feeling that this is very easy but I can't quite figure out how to do it. Say I have a Numpy array
[1,2,3,4]
How do I convert this to
[[1],[2],[3],[4]]
In an easy way?
Thanks
You can use
|
|||
|
|
||||
|
You can use numpy.reshape:
If you want normal python list then use
|
||||
|
The most obvious way that comes to mind is:
but this creates normal Python's list of lists, I'm not sure if this is what you want... |
|||
|
np.array([1, 2, 3, 4])
tonp.array([[1], [2], [3], [4]])
? Or convert it to a traditional Python list of lists? – David Robinson Jul 4 '13 at 19:28