datas = [['RAC1','CD0287',1.52], ['RAC1','CD0695',2.08], ['RAC1','ADN103-1',2.01], ['RAC3','CD0258',1.91], ['RAC3','ADN103-3',1.66], ['RAC8','CD0558',1.32], ['RAC8','ADN103-8',2.89]]
labels = ['Plate', 'Sample', 'LogRatio']
df = pd.DataFrame(data = datas, columns=labels, index=[8, 3, 5, 4, 12, 44, 2])
Plate Sample LogRatio
8 RAC1 CD0287 1.52
3 RAC1 CD0695 2.08
5 RAC1 ADN103-1 2.01
4 RAC3 CD0258 1.91
12 RAC3 ADN103-3 1.66
44 RAC8 CD0558 1.32
2 RAC8 ADN103-8 2.89
我想用索引找到位于“CD0695”样本后面n行的样本的logratio值。在
^{pr2}$我不知道如何只有一个索引而不是一个列表,所以我只取列表的第一个元素indexCD0695[0]
,这不是我最大的问题。
我真正的问题是在索引位置3+2处获得值,我希望索引从CD0695的位置开始:(我可以只使用df.loc
)并在这个起始索引之后有第二行:
4 RAC3 CD0258 1.91
所以logratio值是1.91
我想我必须混合df.loc[indexCD0695]
和{
使用^{} 获取通过索引标签的特定行的序号位置,然后可以使用
iloc
获取该行后面的第n行:另一个选择是在提取值之前将
LogRatio
列移动n
:相关问题 更多 >
编程相关推荐