ValueError: zero-size array to reduction operation minimum which has no identity
时间: 2024-06-13 14:07:17 浏览: 17
ValueError: zero-size array to reduction operation minimum which has no identity is a common error that occurs when you try to perform a mathematical operation on an empty array or a
zero-length list. This error occurs because the operation requires at least one element in the array, but the array is empty.
For example, if you try to calculate the sum of all elements in an empty array using the built-in Python function sum(), you will get this error:
```
>>> numbers = []
>>> sum(numbers)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in <listcomp>
ValueError: zero-size array to reduction operation minimum which has no identity
```
To fix this error, make sure that the array or list you are trying to operate on contains at least one element before performing any mathematical operations on it.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)