我有这样的面具记录
In [41]: x
Out[41]:
masked_records(
CHR : [12 12 12 ..., 12 12 12]
SNP : [rs4980929 rs4980929 rs4980929 ..., rs7975069 rs7975069 rs7975069]
A1 : [C C C ..., T T T]
A2 : [T T T ..., C C C]
TEST : [GENO TREND ALLELIC ..., ALLELIC DOM REC]
AFF : [51/126/92 228/310 228/310 ..., 190/350 158/112 32/238]
UNAFF : [51/136/83 238/302 238/302 ..., 180/362 148/123 32/239]
CHISQ : [0.8427 0.3124 0.3155 ..., 0.4688 0.8398 0.000248]
DF : [2 1 1 ..., 1 1 1]
P : [0.6562 0.5762 0.5744 ..., 0.4935 0.3594 0.9874]
fill_value : (999999, 'N/A', 'N', 'N', 'N/A', 'N/A', 'N/A', 1e+20, 999999, 1e+20)
我如何从P获得TEST =='GENO'的价值?如果有此帮助,“P”字段缺少值。
答案 0 :(得分:2)
它应该简单x['P'][x['TEST'] == 'GENO']
e.g。
import numpy as np
# Make some fake data:
x = np.zeros(10, dtype={'names':['P', 'TEST'], 'formats':[np.int, '|S5']})
x['P'] = np.arange(10)
x['TEST'] = ['GENO', 'TREND', 'ALLEL', 'DOM', 'REC',
'GENO', 'TREND', 'DOM', 'ALLEL', 'REC']
# Get values in field "P" where field "TEST" == "GENO":
print x['P'][x['TEST'] == 'GENO']