python - df.apply(lambda: x.lower()): 'function' 对象没有属性 'lower'
问题描述
我在 Jupyter 中编写了这段代码,但收到一条错误消息:
tokenizer = RegexpTokenizer (r'\w+')
career_df['How could the conversation have been more useful?']= career_df['How could the conversation have been more useful?'].apply(lambda x:tokenizer.tokenize(x.lower()))
错误是
AttributeError:'function'对象没有属性'lower'
解决方案
lambda 表达式中的“x”在应该是字符串时充当函数。尝试 :
career_df['How could the conversation have been more useful?']= career_df.apply(lambda x:tokenizer.tokenize(x['How could the conversation have been more useful?'].lower()))
推荐阅读
- android - 如何创建 Intent 方法
- python - 如何替换来自 GitHub 的原始文件中的 \n、b 和单引号?
- r - 将行折叠到每组中的最低完整行
- python - 使用非方形输入矩阵进行卷积自动编码器
- powershell - 您如何快速停止/启动 140 多台服务器上的服务?
- angular - NGRX 商店更换
- hazelcast - Hazelcast Openfire 插件是否允许 SSL?
- git - 从 git-svn 迁移到 git
- swift - “ViewController”类型的值没有成员“ref”;您指的是 'self' 吗?firebase 迅速出错
- c++ - Value * -> getName 返回空字符串 LLVM