我可能没有使用正确的关键字来找到一些有用的东西(你可能可以从这个尴尬的标题中看出这一点),所以这里是:
如何表示单个列表中成对的值?例如,这个列表可以是一个团队联盟(比如说红色、金色和蓝色以保持简短)相互竞争,并且每个游戏的结果值。每个列表项(团队)与所有其他项配对,并且每个配对对应一个值,我们可以将其称为结果。通常使用这种结构的方法是挑选两支球队来查看比赛结果。双人不分先后顺序,团队也没有特殊状态。你知道吗
最明显的是一个表(例如,我使用的是Pandas,所以是dataframe),但感觉有点尴尬,因为如果我们要避免重复,它必须是半满的。你知道吗
“团队”之间可能有两个“游戏”(这在体育运动中很常见),但在这种情况下,我认为表格会更糟,因为我们必须给对角线上方和下方的部分赋予一些含义(比如“第1轮”和“第2轮”),而且它不能概括为更多的匹配(应该在“单个”列表的顶部添加一个额外的变量)。你知道吗
什么是“自然的”(代替更好的术语)来表示这一点?(通过这个,我指的是原始表,即来自单个列表的无序对)
p.S.:我提到了数据帧,但这个问题适用于任何类型的“表”(例如dict of dicts)。你知道吗
p.S.2:我提到“团队”只是为了说明。请避免讨论与运动有关的问题!你知道吗
我建议用一本字典,可能是
例如
也就是说
我觉得做东西比较好。你知道吗
在python文件中:
如果执行该文件,它将输出:
编辑:班级联盟
它输出:
这能回答你的问题吗?你知道吗
如果您想像第一个问题中那样显示一个更直观的表,那么制作一个GUI应该更有效。你知道吗
相关问题 更多 >
编程相关推荐