ดังนั้นฉันจึงมีดาต้าเฟรมแพนด้าพร้อมแถวของสตริงโทเค็นในคอลัมน์ชื่อเรื่องราว ฉันยังมีรายการคำในรายการชื่อ Selected_words ด้วย ฉันกำลังพยายามนับอินสแตนซ์ของ select_words ใด ๆ ในแต่ละแถวในเรื่องของคอลัมน์
รหัสที่ฉันใช้ก่อนหน้านี้ได้ผลคือ
CCwordsCount=df4.story.str.count('|'.join(selected_words))
ตอนนี้ให้ค่า NaN แก่ฉันทุกแถว
ด้านล่างนี้คือสองสามแถวแรกของเรื่องราวของคอลัมน์ใน df4 dataframe มีบทความ NYTimes มากกว่า 400 แถวเล็กน้อย
0 [it, was, a, curious, choice, for, the, good, ...
1 [when, he, was, a, yale, law, school, student,...
2 [video, bitcoin, has, real, world, investors, ...
3 [bitcoin, s, wild, ride, may, not, have, been,...
4 [amid, the, incense, cheap, art, and, herbal, ...
5 [san, francisco, eight, years, ago, ernie, all...
นี่คือรายการของ Selected_words
selected_words = ['accept', 'believe', 'trust', 'accepted', 'accepts', 'trusts', 'believes', \
'acceptance', 'trusted', 'trusting', 'accepting', 'believes', 'believing', 'believed',\
'normal', 'normalize', ' normalized', 'routine', 'belief', 'faith', 'confidence', 'adoption', \
'adopt', 'adopted', 'embrace', 'approve', 'approval', 'approved', 'approves']
["it, was, a, curious, choice, for, the, good, ..."]
หรือไม่ - person DarrylG   schedule 13.05.2020