擅长:python、mysql、java
<p>演示:</p>
<pre><code>In [84]: df
Out[84]:
a b c new
0 1 11 aaa True
1 2 22 bbb False
2 3 33 ccc True
3 4 44 ddd False
In [85]: lst = ['aaa','ccc','xxx']
In [86]: df['new'] = df['c'].isin(lst).astype(np.int8)
In [87]: df
Out[87]:
a b c new
0 1 11 aaa 1
1 2 22 bbb 0
2 3 33 ccc 1
3 4 44 ddd 0
</code></pre>
<p>PS您根本不需要使用CSV模块:</p>
<pre><code>df = pd.read_csv(r'/path/to/biosample.csv', delimiter = ',',
encoding='unicode', error_bad_lines=False,
index_col='Sample_Info')
</code></pre>