NumPy - Aggregation Functions
What is wrong with this code snippet?
arr = np.array([[1, 2], [3, 4]]) result = np.mean(arr, axis=2)
arr = np.array([[1, 2], [3, 4]]) result = np.mean(arr, axis=2)
arr is 2D with shape (2,2), so valid axes are 0 and 1.axis=2 is invalid and causes an error because axis 2 does not exist.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions