.min(axis=0)
时间: 2024-05-12 18:20:16 浏览: 13
The ".min(axis=0)" method calculates the minimum value along the axis 0 (i.e., the columns) of a numpy array.
For example, if we have a 2D numpy array "arr" with shape (3,4), calling "arr.min(axis=0)" will return a 1D numpy array with length 4, containing the minimum value of each column in "arr".
Here is an example code snippet to demonstrate this:
```python
import numpy as np
arr = np.array([[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]])
min_cols = arr.min(axis=0)
print(min_cols) # Output: [1 2 3 4]
```
In this example, "min_cols" will contain the minimum value of each column in "arr". The first element of "min_cols" is 1, which is the minimum value in the first column of "arr". The second element of "min_cols" is 2, which is the minimum value in the second column of "arr", and so on.