擅长:python、mysql、java
<p>问题是要在中查找子字符串<code>remoaners</code>的字符串包含在每个单元格的<code>list</code>中。在执行<code>str.contains</code>之前,您需要通过执行<code>str[0]</code>来访问此字符串,例如:</p>
<pre><code># input
time_plus_text = pd.DataFrame({'text':[['#bbcqt Remoaners on about post Brexit racial...'],
['@sarahwollaston Shut up, you like all remoaners...'],
['what have the Brextremists ever done for us ...']]})
print (time_plus_text["text"].str[0].str.contains("remoaners", case=False, na=False))
0 True
1 True
2 False
Name: text, dtype: bool
</code></pre>
<p>所以你应该:</p>
<pre><code>remoaners_only = time_plus_text[time_plus_text["text"].str[0]\
.str.contains("remoaners", case=False, na=False)]
</code></pre>