python中的数据表

问题描述

如何创建类似于下表的数据表?

         (1) (2) (3) (4) 
    (1,2).3  .6   0   0
    (1,3).25  0  .75  0
    (1,4).2   0   0  .8
    (2,3) 0  .4  .6   0
    (2,4) 0  .3  .6   0  
    (3,4) 0   0  .42 .57
  (1,2,3).16 .3  .5   0
  (1,3,4).12  0  .37 .5
(1,4).1  .2  .3  .4
Rows

行是数组的所有排列,列是数组的所有值。 数据是排列中的每个值除以排列中所有值的总和。 以下是获取值的代码

from itertools import combinations,chain
n = int(input("Enter The Amount of Numbers in the List: ")
)
z = []
p = []
q = []
for i in range(0,n):
  x = float(input("Enter the numbers: "))
  q.append(x)
c = list(chain.from_iterable([list(combinations(q,i)) for i in range(2,len(q)+1)]))
results = []
for x in c:
    for n in range(len(x)):
      results.append([x[n]/sum(x)])

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...