开发者

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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜