擅长:python、mysql、java
<p>从csv文件加载数据帧时,不需要使用csv模块。你知道吗</p>
<p>正如您所提到的,新列应该添加到dataframe。你知道吗</p>
<p>用于检查来自第一个列表的值的代码可能如下所示:</p>
<pre><code>import pandas as pd
list1 = ['UC''iCD', 'Chrons disease', 'Chrons', 'IBD', 'Ulcerative colitis', 'PMC', 'P80', 'Chron disease']
list2 = ['Donor', 'healthy', 'non-IBD', 'Control']
def check_list(value, list2check):
if any(map(lambda x: x in value, list2check))
return 1
return 0
df = pd.read_csv('biosample.csv', delimiter = ',', dtype= 'unicode', error_bad_lines=False)
df['sample_from_list1'] = df['Sample_Info'].apply(lambda v: check_list(v, list1))
</code></pre>