这是我的密码
import numpy as np
contrainte1= 1080*0.65 # minutes tous les jours
contrainte2= 720*0.55 # minutes du lundi au vendredi
X=np.array([[9, 48],[12, 46],[14, 41],[12, 45],[6, 50],[10, 48],[25, 12],[26, 15],[30, 10],[31, 16],[40, 10],[41, 12],[35, 18],[35, 19],[30, 21],[28, 21],[25, 24],[21, 28],[22, 30],[25, 26],[26, 25],[30, 20],[32, 16],[35, 12]])<
#La première position représente la contrainte 1
#La deuxième position représente la contraire 2
# contrainte 1
for i in X[-19:]:
print(i)
for y in #This is where I need help我想为每个数组(I)执行一个循环,其中我将对数组的第一部分中的每个值进行求和。例如,我希望能够用np.sum()进行9+12+14....+35之和。
当我尝试像SciPy向我展示的那样索引时,我似乎找不到做我想做的事情的技术。或者我只是不明白(语言障碍)
谢谢
发布于 2017-10-03 01:10:18
如果我明白你的意思,你只想和第一列中的元素求和?所需要的只是一点索引和sum
In [19]: X[:, 0].sum()
Out[19]: 600https://stackoverflow.com/questions/46535773
复制相似问题