小编Sur*_*ngh的帖子

“function”对象没有属性“apply”

我有一个数据框 df ,其中有一列包含文本数据的“查询”。

我正在尝试借助 apply 函数来清理文本数据。但出现上述错误。我的代码是:

def _remove_noise(input_text):
    input_text = str(input_text).encode('ascii', 'ignore')
    input_text = str(input_text).replace(",", "")
    return input_text
Run Code Online (Sandbox Code Playgroud)

当我使用 apply 函数调用上述函数时,如下所示:

df['query1'] = df.query.apply(_remove_noise)
Run Code Online (Sandbox Code Playgroud)

它抛出的错误为:

“function”对象没有属性“apply”

python apply pandas

1
推荐指数
1
解决办法
8351
查看次数

标签 统计

apply ×1

pandas ×1

python ×1