You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于原始DataFrame生成列表形式的行存在性标记DataFrame

问题背景

原始DataFrame

H1 H2  H3  H4  H5
A1   1  0   0   1   0
A2   1  0   0   1   0
A3   1  1   0   0   0
A4   1  0   1   0   0
A5   1  0   1   0   1
A6   1  1   1   0   0
A7   1  0   1   0   0
A8   1  0   1   0   1
A9   1  1   1   0   0

以列表形式存储的DataFrames

# list_of_dataframes
[
     H1 H2  H3  H4  H5
A2   1  0   0   1   0
A3   1  1   0   0   0
A4   1  0   1   0   0
A5   1  0   1   0   1
A6   1  1   1   0   0,
     H1 H2  H3  H4  H5
A1   1  0   0   1   0
A3   1  1   0   0   0
A7   1  0   1   0   0
A8   1  0   1   0   1
A9   1  1   1   0   0
]

需求说明

生成以列表形式存储的输出DataFrame,需满足:

  • 保留原始DataFrame的所有行索引和列索引;
  • 对于列表中的每个DataFrame,若原始DataFrame的某一行存在于该DataFrame中,则该行的所有列填充为1,否则填充为0。

预期输出

# list of Output dataframe 
[
        H1 H2  H3  H4  H5
  A1    0  0   0   0   0
  A2    1  1   1   1   1
  A3    1  1   1   1   1
  A4    1  1   1   1   1
  A5    1  1   1   1   1
  A6    1  1   1   1   1
  A7    0  0   0   0   0
  A8    0  0   0   0   0
  A9    0  0   0   0   0,
           H1   H2  H3  H4  H5
      A1   1    1   1   1   1
      A2   0    0   0   0   0
      A3   1    1   1   1   1
      A4   0    0   0   0   0
      A5   0    0   0   0   0
      A6   0    0   0   0   0
      A7   1    1   1   1   1
      A8   1    1   1   1   1
      A9   1    1   1   1   1
]

内容的提问来源于stack exchange,提问作者Noorulain Islam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 07:37:03