'DataFrame' object has no attribute 'isna'

匿名 (未验证) 提交于 2019-12-03 01:18:02

问题:

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

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.

回答1:

Is 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.

In fact the 0.22 documentation for isnull states

alias of isna

For your version, try isnull, therefore.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!