这是我的阵列/三维数组列表的输出(不知道它是什么),我不明白为什么单词数组在那里,但我希望&和#39;这不是我无法计算最大值的原因,我通过计算数据集的列之间的Pearson r值来获得此列表。
[array([[ 1. , 0.31276108],
[ 0.31276108, 1. ]]), array([[ 1. , 0.23618345],
[ 0.23618345, 1. ]]), array([[ 1. , 0.31610011],
[ 0.31610011, 1. ]]), array([[ 1. , 0.3304167],
[ 0.3304167, 1. ]]), array([[ 1. , -0.31138519],
[-0.31138519, 1. ]]), array([[ 1. , 0.49419313],
[ 0.49419313, 1. ]]), array([[ 1. , 0.49811488],
[ 0.49811488, 1. ]]), array([[ 1. , 0.39335085],
[ 0.39335085, 1. ]]), array([[ 1. , -0.44059693],
[-0.44059693, 1. ]]), array([[ 1. , 0.22362626],
[ 0.22362626, 1. ]]), array([[ 1. , -0.19201056],
[-0.19201056, 1. ]]), array([[ 1. , 0.64372004],
[ 0.64372004, 1. ]]), array([[ 1. , -0.63371678],
[-0.63371678, 1. ]]), array([[ 1. , 0.56546829],
[ 0.56546829, 1. ]]), array([[ 1. , -0.42881494],
[-0.42881494, 1. ]]), array([[ 1. , 0.5190671],
[ 0.5190671, 1. ]]), array([[ 1. , -0.5032696],
[-0.5032696, 1. ]]), array([[ 1. , 0.7871939],
[ 0.7871939, 1. ]]), array([[ 1. , 0.69994936],
[ 0.69994936, 1. ]]), array([[ 1. , 0.06600394],
[ 0.06600394, 1. ]]), array([[ 1. , -0.27676855],
[-0.27676855, 1. ]]), array([[ 1. , 0.00391123],
[ 0.00391123, 1. ]]), array([[ 1. , -0.36871043],
[-0.36871043, 1. ]]), array([[ 1. , 0.07234319],
[ 0.07234319, 1. ]]), array([[ 1. , -0.78822959],
[-0.78822959, 1. ]]), array([[ 1. , -0.52181319],
[-0.52181319, 1. ]]), array([[ 1. , 0.29554425],
[ 0.29554425, 1. ]]), array([[ 1. , -0.26263963],
[-0.26263963, 1. ]]), array([[ 1. , 0.54347857],
[ 0.54347857, 1. ]]), array([[ 1. , 0.43368134],
[ 0.43368134, 1. ]]), array([[ 1. , 0.0553982],
[ 0.0553982, 1. ]]), array([[ 1. , -0.27395522],
[-0.27395522, 1. ]]), array([[ 1. , -0.07466689],
[-0.07466689, 1. ]]), array([[ 1. , -0.56129569],
[-0.56129569, 1. ]]), array([[ 1. , -0.0717472],
[-0.0717472, 1. ]]), array([[ 1. , -0.61736921],
[-0.61736921, 1. ]]), array([[ 1. , -0.02524993],
[-0.02524993, 1. ]]), array([[ 1. , 0.13905701],
[ 0.13905701, 1. ]]), array([[ 1. , -0.1723794],
[-0.1723794, 1. ]]), array([[ 1. , -0.05513642],
[-0.05513642, 1. ]]), array([[ 1. , 0.19995001],
[ 0.19995001, 1. ]]), array([[ 1. , 0.01873198],
[ 0.01873198, 1. ]]), array([[ 1. , 0.25888726],
[ 0.25888726, 1. ]]), array([[ 1. , 0.24898534],
[ 0.24898534, 1. ]]), array([[ 1. , 0.5463642],
[ 0.5463642, 1. ]]), array([[ 1. , 0.26566757],
[ 0.26566757, 1. ]]), array([[ 1. , -0.3658451],
[-0.3658451, 1. ]]), array([[ 1. , 0.65269177],
[ 0.65269177, 1. ]]), array([[ 1. , 0.61241308],
[ 0.61241308, 1. ]]), array([[ 1. , 0.23644061],
[ 0.23644061, 1. ]]), array([[ 1. , -0.19732684],
[-0.19732684, 1. ]]), array([[ 1. , 0.00965194],
[ 0.00965194, 1. ]]), array([[ 1. , -0.22074619],
[-0.22074619, 1. ]]), array([[ 1. , 0.13669791],
[ 0.13669791, 1. ]]), array([[ 1. , -0.49912982],
[-0.49912982, 1. ]]), array([[ 1. , -0.53789961],
[-0.53789961, 1. ]]), array([[ 1. , -0.4499353],
[-0.4499353, 1. ]]), array([[ 1. , -0.25629405],
[-0.25629405, 1. ]]), array([[ 1. , 0.36192172],
[ 0.36192172, 1. ]]), array([[ 1. , 0.18623045],
[ 0.18623045, 1. ]]), array([[ 1. , 0.29297713],
[ 0.29297713, 1. ]]), array([[ 1. , -0.15592947],
[-0.15592947, 1. ]]), array([[ 1. , 0.48910916],
[ 0.48910916, 1. ]]), array([[ 1. , 0.8645635],
[ 0.8645635, 1. ]]), array([[ 1. , 0.19578377],
[ 0.19578377, 1. ]]), array([[ 1. , -0.35136986],
[-0.35136986, 1. ]]), array([[ 1. , 0.11507728],
[ 0.11507728, 1. ]]), array([[ 1. , -0.41100659],
[-0.41100659, 1. ]]), array([[ 1. , 0.23681493],
[ 0.23681493, 1. ]]), array([[ 1. , -0.84749754],
[-0.84749754, 1. ]]), array([[ 1. , 0.21440123],
[ 0.21440123, 1. ]]), array([[ 1. , -0.32111332],
[-0.32111332, 1. ]]), array([[ 1. , 0.12897954],
[ 0.12897954, 1. ]]), array([[ 1. , -0.335167],
[-0.335167, 1. ]]), array([[ 1. , 0.28910112],
[ 0.28910112, 1. ]]), array([[ 1. , -0.71916334],
[-0.71916334, 1. ]]), array([[ 1. , -0.08333309],
[-0.08333309, 1. ]]), array([[ 1. , 0.28658669],
[ 0.28658669, 1. ]]), array([[ 1. , -0.0545751],
[-0.0545751, 1. ]]), array([[ 1. , 0.27079823],
[ 0.27079823, 1. ]]), array([[ 1. , -0.20917939],
[-0.20917939, 1. ]]), array([[ 1. , 0.44336719],
[ 0.44336719, 1. ]]), array([[ 1. , 0.2885004],
[ 0.2885004, 1. ]]), array([[ 1. , -0.31023514],
[-0.31023514, 1. ]]), array([[ 1. , 0.51785911],
[ 0.51785911, 1. ]]), array([[ 1. , 0.16404547],
[ 0.16404547, 1. ]]), array([[ 1. , 0.2115446],
[ 0.2115446, 1. ]]), array([[ 1. , -0.04964322],
[-0.04964322, 1. ]]), array([[ 1. , 0.09439694],
[ 0.09439694, 1. ]]), array([[ 1. , 0.4377762],
[ 0.4377762, 1. ]]), array([[ 1. , -0.32822194],
[-0.32822194, 1. ]])]
以下是我找到最大值的代码
for i in range(len(r)):
for j in range(len(r)):
if r[i][1][0]==r[j][1][0]:
data=r[i][1][0]
elif r[i][1][0] < r[j][1][0]:
data=r[j][1][0]
else:
data=r[i][1][0]
这给了我-0.328的输出,通过检查显然最大值是0.79
答案 0 :(得分:0)
我怀疑无论是什么让你陷入困境并不是尝试实现你正在做的任何事情的最佳方式。但是,让我们说你的2x2数组列表是a
,你知道给定的2x2数组的反对角线的值是相同的,那么你可以这样做:
max(arr[0,1] for arr in a)
如果你不确定他们总是平等的话,你可以使用这样的东西:
max(np.flipud(arr).diagonal().max() for arr in a)