E:\python\python.exe D:\pythonprojects\PycharmProjects\数学建模\数学建模2023省赛2\test\2.py 用户编号 0 : 用户编号 Traceback (most recent call last): File "D:\pythonprojects\PycharmProjects\数学建模\数学建模2023省赛2\test\2.py", line 20, in <module> data_list = [0 if isinstance(x, str) and np.isnull(x) else x for x in data_list] File "D:\pythonprojects\PycharmProjects\数学建模\数学建模2023省赛2\test\2.py", line 20, in <listcomp> data_list = [0 if isinstance(x, str) and np.isnull(x) else x for x in data_list] File "E:\python\lib\site-packages\numpy\__init__.py", line 320, in __getattr__ raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'isnull'
时间: 2023-08-10 17:05:50 浏览: 86
抱歉,我之前给出的解决方案有误。`np.isnull()`确实是用来判断空值的函数,但是它是pandas库中的函数,而不是NumPy库中的函数。在你的代码中,你已经正确地导入了NumPy库作为`np`,所以你可以使用`np.isnan()`来判断空值。请尝试以下修改:
```python
data_list = [0 if isinstance(x, str) and np.isnan(x) else x for x in data_list]
```
这样修改后,你的代码应该能够正常运行了。再次抱歉给你带来的困扰。
阅读全文