将功能应用于多行

时间:2019-10-10 21:50:43

标签: python pandas function

code and data sample

newdf = pd.DataFrame()
newdf['genes in system'] = df_bladder['Genes (Alphabetical order)']
#systemlist = [newdf['genes in system'][x].split(' ') for x in range (0,len(newdf))]
#bladderlist = bladderlist.append(i) if i 
def query(df): 
    genes = [i for i in newdf['genes in system'][0].split(' ') if i in list(combined_df)]
    return genes
newdf['genes in'] = newdf['genes in system'].apply(query)
newdf

我正在尝试应用此函数,该函数从与我的列表(list(combined_df))匹配的第一列中提取字符串。但是,它仅从第一行提取。

0 个答案:

没有答案