在这个系列中,isnull()在列表理解中不起作用

2024-06-08 10:03:48 发布

您现在位置:Python中文网/ 问答频道 /正文

对于以下简单代码:

drop_cols = [col for col in train.columns if col[0] == 'V' and train[col].isnulll().sum()/len(train) > 0.76]
drop_cols

我得到这个错误:

AttributeError Traceback (most recent call last) in () ----> 1 drop_cols = [col for col in train.columns if col[0] == 'V' and train[col].isnulll().sum()/len(train) > 0.76] 2 drop_cols

in (.0) ----> 1 drop_cols = [col for col in train.columns if col[0] == 'V' and train[col].isnulll().sum()/len(train) > 0.76] 2 drop_cols

C:\Anaconda3\lib\site-packages\pandas\core\generic.py in getattr(self, name) 5065 if self._info_axis._can_hold_identifiers_and_holds_name(name): 5066
return self[name] -> 5067 return object.getattribute(self, name) 5068 5069 def setattr(self, name, value):

AttributeError: 'Series' object has no attribute 'isnulll'

isnull()正在其他地方工作。这是什么原因和解决办法


Tags: columnsandnameinselfforlenif
1条回答
网友
1楼 · 发布于 2024-06-08 10:03:48

不幸的是,我没有超过50个代表点添加评论,所以需要在这里回复

您只需在代码train[col].isnulll().sum()/len(train)(triple lll)中输入一个拼写错误

drop_cols = [col for col in train.columns if col[0] == 'V' and train[col].isnull().sum()/len(train) > 0.76]

相关问题 更多 >