2

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?

1 Answer 1

3

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]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.