我的CSV文件中有一列,我想在其中搜索字符串列表并添加一个0/1的新列,如果列表中存在任何值,则1或0。你知道吗
我有两张单子:
我的专栏也有NA值
到目前为止,我有一个,我只是试图匹配列表的刺:
import csv
import pandas as pd
with open('biosample.csv') as csvfile:
df = pd.read_csv('biosample.csv', delimiter = ',', dtype= 'unicode',
error_bad_lines=False)
df1 = df.set_index(['Sample_Info'])
print(df1.loc['UC''iCD', 'Chrons disease', 'Chrons', 'IBD', 'Ulcerative
colitis', 'PMC', 'P80', 'Chron disease])
对此,我得到了多个错误,如in\u has\u valid\u type\u error,in has\u valid\u type\u error。你知道吗
我已经通过已经张贴的问题,但没有这种错误被提及。你知道吗
演示:
PS您根本不需要使用CSV模块:
从csv文件加载数据帧时,不需要使用csv模块。你知道吗
正如您所提到的,新列应该添加到dataframe。你知道吗
用于检查来自第一个列表的值的代码可能如下所示:
相关问题 更多 >
编程相关推荐