Pandas; Select 个数据框中基于此数据框的行
Pandas; Select rows in one data frame based on this data frame
我有两个 pandas 数据框。我想 select 根据每条记录中的字段是否高于此数据框中的值以及同一字段是否低于另一组中的值来 select 一个数据框中的记录子集。
下面给出了第一个数据框中值超过我的截止值的所有记录:
roi_upregulated_genes = roi[roi['zscore']>CUTOFF]
如何在df_two
中找到相应的zscore。两个数据框具有相同的列名。
逻辑是这样的
roi_selectively_upregulated_genes = [gene for gene in roi_upregulated_genes if control[gene][zscore] < CUTOFF]
如何在 Pandas 中做到这一点?我不能使用索引,我必须通过字段 gene
.
在表之间进行交叉引用
由于您尚未发布任何原始数据和代码,因此我认为这应该有效
lhs = roi[roi['zscore']>CUTOFF]
rhs = control[control['zscore']<CUTOFF]
combined = lhs.merge(rhs, on='gene', how='inner')
这将只为您提供两个子集中都存在的基因
我有两个 pandas 数据框。我想 select 根据每条记录中的字段是否高于此数据框中的值以及同一字段是否低于另一组中的值来 select 一个数据框中的记录子集。
下面给出了第一个数据框中值超过我的截止值的所有记录:
roi_upregulated_genes = roi[roi['zscore']>CUTOFF]
如何在df_two
中找到相应的zscore。两个数据框具有相同的列名。
逻辑是这样的
roi_selectively_upregulated_genes = [gene for gene in roi_upregulated_genes if control[gene][zscore] < CUTOFF]
如何在 Pandas 中做到这一点?我不能使用索引,我必须通过字段 gene
.
由于您尚未发布任何原始数据和代码,因此我认为这应该有效
lhs = roi[roi['zscore']>CUTOFF]
rhs = control[control['zscore']<CUTOFF]
combined = lhs.merge(rhs, on='gene', how='inner')
这将只为您提供两个子集中都存在的基因