<p>你的代码行得通。因此,您需要检查您的输入数据或pandas错误修复版本,即0.24.1 vs 0.24.2。你知道吗</p>
<pre><code>0.24.2
index text
0 0 [ #bbcqt Remoaners on about post Brexit rac...
</code></pre>
<pre><code>import pandas as pd
import sys
if sys.version_info[0] < 3:
from StringIO import StringIO
else:
from io import StringIO
print(pd.__version__)
csvdata = StringIO("""0, [ #bbcqt Remoaners on about post Brexit racial...
1, [@sarahwollaston Shut up, you like all remoane...
2, [ what have the Brextremists ever done for us ...
3, [ Remoaner in bizarre outburst ]
4, [ Anyone who disagrees with brexit is called n...
5, [ @SkyNewsBreak They forecasted if the vote wa...
6, [ but we ARE LEAVING THE #EU, even the #TORIES...
7, [ Can unelected Remoaner peers not see how abs...
8, [@sizjam68 @LeaveEUOfficial @johnredwood It wo...
9, [ Hey @BBC have you explained why when award w...""")
df = pd.read_csv(csvdata, names=["index", "text"], sep=",")
result = df[df["text"].str.contains("remoaners", case=False, na=False)]
# results
print(result)
</code></pre>