numpy:从屏蔽记录中查询数据?

发布于 2024-11-02 14:54:04 字数 745 浏览 4 评论 0原文

我有这样的掩码记录

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 where TEST == 'GENO' 获取值?如果这有帮助,则“P”字段缺少值。

I have mask record like this

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)

How do I get value from P where TEST == 'GENO' ? If this help, 'P' field has a missing value.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜未央樱花落 2024-11-09 14:54:04

它应该是简单的 x['P'][x['TEST'] == 'GENO']

例如

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']

It should be as simple a 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']
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文