-->

'DataFrame' object has no attribute 'i

2020-08-26 04:08发布

问题:

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:

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.

In fact the 0.22 documentation for isnull states

alias of isna

For your version, try isnull, therefore.



标签: python pandas