分配失败,Pandas安静

2024-05-29 05:53:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我对熊猫有一个很奇怪的问题。你知道吗

在最后一行,我得到一个键错误。熊猫无法取回自我。态度[用户],尽管它应该在前一行设置。你知道吗

有人能告诉我出了什么问题吗?你知道吗

https://sourceforge.net/p/commonground/code/HEAD/tree/CommonGround.py

编辑

def add_document(self,user,uri,document):
    """Calculates the sentiment score, and topic vector for the document,
       and updates the users's attitude vector"""

    self.Sentiments.loc[(user,uri)]=sum([emotion['compound'] 
                                        for emotion in (self.vader.polarity_scores(sentence)
                                                        for sentence in sentence_splitter.split(document))])
    self.Topics.loc[(user,uri),:]=pandas.Series(dict(self.model[self.get_features(document)]))
    self.Topics.fillna(0.0,inplace=True)
    self.Attitudes.loc[user]=self.Sentiments.loc[user].dot(self.Topics.loc[user])
    self.modulus.loc[user]=numpy.linalg.norm(self.Attitudes[user])

self.Sentimentsself.modulusSeries对象。self.Topicsself.AttitudesDataFrame对象。你知道吗

self.Sentimentsself.Topics具有各自的体系索引(每个索引有2个级别)。你知道吗


Tags: andtheinselfforuridocumentloc

热门问题