【问题标题】:pandas series,isnull() is not working inside list comprehension [closed]pandas series,isnull() 在列表理解中不起作用[关闭]
【发布时间】:2019-08-15 22:38:33
【问题描述】:

以下简单代码:

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(最近调用 最后)在() ----> 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

在 (.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 在 getattr(self, name) 5065 if self._info_axis._can_hold_identifiers_and_holds_name(name): 5066
返回自我[姓名] -> 5067 返回对象。getattribute(self, name) 5068 5069 def setattr(self, name, value):

AttributeError: 'Series' 对象没有属性 'isnulll'

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

【问题讨论】:

  • 您的错误信息包含错字:isnulll 有 3 个小写 L。

标签: python pandas null list-comprehension


【解决方案1】:

很遗憾,我没有超过 50 个代表点来添加评论,所以需要在这里回复。

您只是在代码 train[col].isnulll().sum()/len(train) 中有错字(三重 lll)

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

【讨论】:

    猜你喜欢
    • 2016-08-20
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-27
    相关资源
    最近更新 更多