Python ';数据帧';对象没有属性';设置#u值';
我正在使用Python ';数据帧';对象没有属性';设置#u值';,python,pandas,dataframe,Python,Pandas,Dataframe,我正在使用set_value()函数,但现在它说它已被弃用 据说改为使用.at。我试过这个,但对我不起作用 范围(0,len(text))中的i的: clean=cleaner.clean(str(文本[i])) df.设置_值(i,‘清洁’,清洁) 尝试: #translated\u tweet=translator.translate(clean.text) translated\u tweet=translator.translate(clean.text) df.set_值(i,‘翻译’
set_value
()函数,但现在它说它已被弃用
据说改为使用.at
。我试过这个,但对我不起作用
范围(0,len(text))中的i的:
clean=cleaner.clean(str(文本[i]))
df.设置_值(i,‘清洁’,清洁)
尝试:
#translated\u tweet=translator.translate(clean.text)
translated\u tweet=translator.translate(clean.text)
df.set_值(i,‘翻译’,翻译的_tweet)
例外情况除外,如e:
打印(str(e))
持续
textB=分析器(翻译的tweet)
分数=textB
df.设置_值(i,“分数”,分数)
如果得分为0.00:
atrb='Poz'
df.set_值(i,'atrb',atrb)
其他:
atrb='Notr'
df.set_值(i,'atrb',atrb)
我如何转换这个?您可以使用“.at”这样:
df.at[“YOURINDEX”,“YOURCOLUMN”]=“YOURVALUE”
因此,在您的示例中,score代码片段如下所示:
df.at[i, 'score'] = score
df.loc[i, 'score'] = score
或者,您也应该能够像这样使用.loc[]:
df.at[i, 'score'] = score
df.loc[i, 'score'] = score