mainArray=np.linspace(1,50,50)
##group1 is first 10 elements of mainArray
group1=np.array(1,2,3...10)
group2=np.array(11,12,13...20)
group3=np.array(21,22,23...30)
.
.
group5=np.array(41,42,43,44,45,46,47,48,49,50)
#i need to find standart deviation and mean value of these groups
#like np.mean(group1) and np.std(group1) for all groups
#then i have to calculate (group1-meanOfGroup1)/stdOfGroup1 for all groups
#and append it to one list or array.
我不知道,因为我的主要问题是我不能让一个循环,切片mainArray到组,并应用np.mean和np.std与循环我怎样才能解决这个问题。如何用循环切片数组并将操作应用于它们?
例如'有效范围内的(X 0,LEN(值), 10):? –
检查从[itertools(https://docs.python.org/3.6/library/itertools.html?highlight=itertools#module-itertools) – Cilyan
检查numpy的的[基本切片(HTTPS的'grouper'配方:// docs.scipy.org/doc/numpy-1.12.0/reference/arrays.indexing.html)你有你需要的一切。 –