我有 2 个不同的表格文件,为 excel 格式。我想知道特定列的蛋白质组文件中是否存在第一个 excel 文件中的一列(来自“ID”列)的 ID 号(例如“IHD”),如果是,则显示与之相关的价值。有没有办法做到这一点,特别是在 Pandas 中,并且可以使用 for 循环?
答案 0 :(得分:1)
使用 read_excel()
加载 excel 文件后,您应该 merge()
ID
和 protein
上的数据框。这是 Pandas 的推荐方法,而不是循环。
import pandas as pd
clusters = pd.read_excel('clusters.xlsx')
proteins = pd.read_excel('proteins.xlsx')
clusters.merge(proteins, left_on='ID', right_on='protein')