Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there an efficient way of splitting a 2-D numpy array(an array of coordinates) to two 1-D numpy arrays?

Here is my array and I would like to separate it to two arrays, one contains all first values of pairs and one with all second values of pairs. Is there an efficient way to do that?

array([[-0.43042553, -0.1224234 ],
       [-2.03524537,  0.56015045],
       [ 1.40186973, -0.74534088],
       [-0.04612834, -0.43374017],
       [-0.71154051, -0.54219998],
       [-0.10434967, -0.80116922],
       [-0.28625899, -1.15067218],
       [ 2.18190517,  0.52953827]])

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Similar to other answers but more concise:

a1, a2 = arr.T
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading