Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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]
Add a comment
Required, but never shown
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.
Explore related questions
See similar questions with these tags.