![](/img/trans.png)
[英]Series objects are mutable, thus they cannot be hashed on Python pandas dataframe
[英]Python : 'Series' objects are mutable, thus they cannot be hashed
我有一个 DataFrame df,文本如下:
|---------------------|-----------------------------------|
| File_name | Content |
|---------------------|-----------------------------------|
| BI1.txt | I am writing this letter ... |
|---------------------|-----------------------------------|
| BI2.txt | Yes ! I would like to pursue... |
|---------------------|-----------------------------------|
我想创建一个额外的列,提供音节计数:
df['syllable_count']= textstat.syllable_count(df['content'])
错误:
Series objects are mutable, thus they cannot be hashed
如何将内容列更改为可散列? 我该如何解决这个错误? 谢谢你的帮助 !
尝试这样做:
df['syllable_count'] = df.content.apply(lambda x: textstat.syllable_count(x))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.