how to solve the "unsupported operand type(s) for -: 'str' and 'str'" error

76 views Asked by At

I am working on some issues of YouTube API that allow me to estimate the influence of the informative side of each video (like, dislike and views count) in forming the user's opinion.

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)

but I faced this problem

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'

can anyone suggest a solution for me?

0

There are 0 answers