-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
  • 107,652
  • 25
  • 181
  • 264
Jacob Walters
  • 77
  • 2
  • 7
  • 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
  • 135
  • 10