Python df.apply(lambda:x.lower()):';功能';对象没有属性';下';
我已经用Jupyter编写了这段代码,但收到一条错误消息:Python df.apply(lambda:x.lower()):';功能';对象没有属性';下';,python,dataframe,stringtokenizer,Python,Dataframe,Stringtokenizer,我已经用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())) 错误是 Attr
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()))