<div>
</div>
<p>我正在尝试使用pandas创建一个列表/数组,其中包含以下文本文件“review/text”字段中的所有单词:</p>
<pre><code>product/productId: B001E4KFG0 review/userId: A3SGXH7AUHU8GW review/profileName: delmartian review/helpfulness: 1/1 review/score:
5.0 review/time: 1303862400 review/summary: Good Quality Dog Food review/text: I have bought several of the Vitality canned dog food products and have found them all to be of good quality. The product looks more like a stew than a processed meat and it smells better. My Labrador is finicky and she appreciates this product better than most.
product/productId: B00813GRG4 review/userId: A1D87F6ZCVE5NK review/profileName: dll pa review/helpfulness: 0/0 review/score: 1.0 review/time: 1346976000 review/summary: Not as Advertised review/text: Product arrived labeled as Jumbo Salted Peanuts...
</code></pre>
<p>(文本文件foods.txt位于:<a href="http://snap.stanford.edu/data/web-FineFoods.html" rel="nofollow noreferrer">http://snap.stanford.edu/data/web-FineFoods.html</a>)</p>
<p>我的最终目标是识别评论/文本字段中出现的所有独特单词</p>
<p>我编写了以下代码:</p>
<pre><code> import pandas as pd
f=open("foods.txt","r")
df=pd.read_csv(f,names=['product/productId','review/userId','review/profileName','review/helpfulness','review/score','review/time','review/summary'])
selected = df[ df['review/summary'] ]
print(selected)
selected.to_csv('result.csv', sep=' ', header=False)
</code></pre>
<p>但是,我得到的错误如下:</p>
<pre><code>ValueError: cannot index with vector containing NA / NaN values
</code></pre>
<p>有什么建议/意见吗</p>