![](/img/trans.png)
[英]How do I create a function that will return a value in a dictionary for each row within a data sheet using Python?
[英]Python function return the same value for each row
您將獲得相同的值,因為每次您傳遞[df.emotion]
時,它都是數據框的整個列,而不是您要處理的值的text
。
如果你想為每一行做postagging,你應該通過以下方式修改你的函數:
def postagging(text):
pos_emotion = ct.tag_sents([text])
return pos_emotion
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.