【发布时间】:2021-10-20 02:28:05
【问题描述】:
如何在flask框架中使用下面的代码,因为我在使用下面的代码时,总是报这个错误“AttributeError: 'numpy.ndarray' object has no attribute 'apply'”
message = message.apply(lambda x: ' '.join([word for word in x.split() if len(word) > 4]))
【问题讨论】:
-
什么是
df?df['full_text']? -
看起来
df本来是一个数据框,但最终成为了一个字典,而df['full_text']是一个 numpy 数组。 -
@3ddavies 否。此代码在我的模型中,但我想在烧瓶框架中使用此代码,但我总是收到错误 AttributeError: 'numpy.ndarray' object has no attribute 'apply '。是不是flask框架不能使用'apply'功能?
-
@hpaulj 数据框,此代码在模型中,但我想将此代码转换为flask框架,以下是转换为flask框架后的消息 = message.apply(lambda x: ' '.join([word for word in x.split() if len(word) > 4])),但我总是出错
标签: python python-3.x numpy text preprocessor