Python Programming - Arrays - Discussion

Discussion Forum : Arrays - General Questions (Q.No. 93)
93.
Given a NumPy array arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), how can you extract the diagonal elements?
arr.diagonal()
arr[1:3, 1:3]
np.diag(arr)
arr[::2, ::2]
Answer: Option
Explanation:
The np.diag() function extracts the diagonal elements of the array.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.