-1

Using numpy, how is it possible to take the array

np.array([[1,2,3],[4,5,6],[7,8,9]])

and get out the arrays

[1,4,7] and [[2,3],[5,6],[8,9]]

Mad Physicist
  • 95,415
  • 23
  • 151
  • 231
Jacob Walters
  • 27
  • 1
  • 4
  • Does this answer your question? [How to access the ith column of a NumPy multidimensional array?](https://stackoverflow.com/questions/4455076/how-to-access-the-ith-column-of-a-numpy-multidimensional-array) – Mad Physicist Aug 30 '20 at 16:38
  • Downvoting because you have not done any research or read any introductory materials before asking. Stack Overflow is not a tutorial site. – Mad Physicist Aug 30 '20 at 16:40

1 Answers1

1

You can use indexing as such :

In [9]: a = np.array([[1,2,3],[4,5,6],[7,8,9]])

In [10]: a[:,0]
Out[10]: array([1, 4, 7])

In [11]: a[:,1:]
Out[11]:
array([[2, 3],
       [5, 6],
       [8, 9]])
Sajid
  • 125
  • 10