Splitting arrays python
I have a 2D array in Python either a normal one or a numpy array with dimensions (150, 5), I wish to split it into two开发者_如何学运维 arrays of dimensions (150, 3) and (150, 2) respectively. Somehow I haven't been able to do it.
Any suggestions?
for numpy arrays you can slice them like this:
a, b = the_array[...,:3], the_array[...,3:]
and with lists of lists (that's what I understand for "normal arrays")
a, b = [i[:3] for i in the_array], [i[3:] for i in the_array]
精彩评论