回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我有一个单词栏:</p>
<pre><code>> print(df['words'])
0 [awww, thats, bummer, shoulda, got, david, car...
1 [upset, that, he, cant, update, his, facebook,...
2 [dived, many, time, ball, managed, save, rest,...
3 [whole, body, feel, itchy, like, it, on, fire]
4 [no, it, not, behaving, at, all, im, mad, why,...
5 [not, whole, crew]
</code></pre>
<p>另一个情感栏是每个单词的“情感”值:</p>
<pre><code>> print(sentiment)
abandon -2
0 abandoned -2
1 abandons -2
2 abducted -2
3 abduction -2
4 abductions -2
5 abhor -3
6 abhorred -3
7 abhorrent -3
8 abhors -3
9 abilities 2
...
</code></pre>
<p>对于<code>df['words']</code>中的每一行单词,我想总结它们各自的情感值。对于感情中不存在的词语,等于0。你知道吗</p>
<p>到目前为止,我的情况是:</p>
<pre><code>df['sentiment_value'] = Sum(df['words'].apply(lambda x: ''.join(x+x for x in sentiment))
</code></pre>
<p>预期结果</p>
<pre><code>print(df['sentiment_value'])
0 -5
1 2
2 15
3 -6
4 -8
...
</code></pre>