我正在研究 YouTube API 的一些问题,这些问题使我能够估计每个视频的信息方面(喜欢、不喜欢和观看次数)对形成用户意见的影响。
dff=pd.read_csv('VideosPolarity.csv')
print(dff)
print(dff.columns)
nv=len(dff) # video number
gamma=0.3
polarity=dff['polarity']
dislike=dff['dislikeCount']
like=dff['likeCount']
view=dff['viewCount']
viewNb=len(view)
channelId=dff['channelId'].unique()
users=len(channelId)
sumpolarity=polarity.sum(axis = 0, skipna = True)
avpolarity=sumpolarity/users
VOpinion=[]
for k in range(0,nv):
value=(((like[k]-dislike[k])/viewNb)*round(avpolarity,1))*round(polarity[k],1)
VOpinion.append(value)
VideoOpinion=gamma*sum(VOpinion)
print('VideoOpinion:',VideoOpinion)
但我遇到了这个问题
TypeError Traceback (most recent call last)
<ipython-input-14-aadb106341f9> in <module>
23 VOpinion=[]
24 for k in range(0,nv):
---> 25 value=(((like[k]-dislike[k])/viewNb)*round(avpolarity,1))*round(polarity[k],1)
26 VOpinion.append(value)
27
TypeError: unsupported operand type(s) for -: 'str' and 'str'
任何人都可以为我提出解决方案吗?