'numpy.ndarray' object has no attribute 'notnull'
时间: 2023-10-13 18:07:06 浏览: 194
将numpy.ndarray格式图像转化为_io.BufferedReader格式
`numpy.ndarray` does not have a `notnull` attribute. The `notnull()` function is part of the pandas library, not NumPy. If you want to check for non-null values in a NumPy array, you can use the `numpy.isnan()` function to check for NaN (Not a Number) values. For example:
``` python
import numpy as np
arr = np.array([1, 2, np.nan, 4, 5])
# Check for non-null values
not_null_mask = ~np.isnan(arr)
print(arr[not_null_mask]) # Prints: [1. 2. 4. 5.]
```
Note that this will only work for arrays with numerical values, as `isnan()` specifically checks for NaN values.
阅读全文