pandas 'DataFrame' 对象没有属性 'isna'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49590874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 05:24:16  来源:igfitidea点击:

'DataFrame' object has no attribute 'isna'

pythonpandas

提问by MikiBelavista

I have adapted one machine learning code for one my project.The code that worked fine on my laptop ,now makes problems on my desktop.I am checking all data frame columns for missing values.

我已经为我的一个项目改编了一个机器学习代码。在我的笔记本电脑上运行良好的代码,现在在我的桌面上出现问题。我正在检查所有数据框列是否有缺失值。

  File "g100.py", line 11, in <module>
    print(dfs.columns[dfs.isna().any()].tolist()) 
AttributeError: 'DataFrame' object has no attribute 'isna'

My installed panda versions and dependencies

我安装的Pandas版本和依赖项

d.show_versions(as_json=False)

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-37-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.20.3
pytest: 3.4.2
pip: 9.0.3
setuptools: 38.5.1
Cython: None
numpy: 1.11.3
scipy: 0.19.0
xarray: None
IPython: 6.2.1
sphinx: None
patsy: 0.5.0
dateutil: 2.6.0
pytz: 2017.3
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.2
openpyxl: None
xlrd: 1.1.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 0.9999999
sqlalchemy: 1.1.9
pymysql: None
psycopg2: 2.7.4 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
pandas_gbq: None
pandas_datareader: 0.6.0

I can find an explanation why isna gives me an AttributeError.

我可以找到解释为什么 isna 给我一个 AttributeError。

回答by Ami Tavory

If you compare the 0.20 documentation for "Working with missing data"with that of 0.22, you can see that the former uses isnull, whereas the latter uses isna.

如果将0.20 的“使用缺失数据”文档0.22 的文档进行比较,您可以看到前者使用isnull,而后者使用isna.

In fact the 0.22 documentation for isnullstates

事实上isnull状态的0.22 文档

alias of isna

isna 的别名

For your version, try isnull, therefore.

对于您的版本,请尝试isnull,因此。