Understanding 'min()' Output in Python with NumPy Arrays
The output you're seeing, '<built-in method min of numpy.ndarray object at 0x00000000024A0C30>', represents the built-in 'min()' method applied to a NumPy ndarray object. It indicates that your code in 'Untitled-1.py' is using the 'min()' function on a NumPy array but isn't printing the result or assigning it to a variable.
To utilize the 'min()' function effectively, you need to either print the result or store it in a variable. Here's how you can modify your code:
- Printing the minimum value:
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(np.min(arr)) # Output: 1
- Storing the minimum value in a variable:
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
minimum_value = np.min(arr)
print(minimum_value) # Output: 1
By either printing the result or assigning it to a variable, you'll see the actual minimum value of the NumPy array instead of the method representation.
原文地址: https://www.cveoy.top/t/topic/hBDv 著作权归作者所有。请勿转载和采集!