3

我真的很难理解如何使用numpy arrays执行计算。

myList = open('key_resp.csv')
newList = np.array(myList)

newList2=sorted(newList)

newLists = open("dataSorted.csv",'w')
writer = csv.writer(newLists)
writer.writerow(newList2)

medNumber=np.median(newLists)

fast = newList2[:len(newList2)//2]
slow = newList2[len(newList2)//2:]


dataFast = open("dataFast.csv",'w')
writer = csv.writer(dataFast)
writer.writerow(fast)

现在对于dataFast我要减去的每个值medNumber

dataFast.csv看起来像[0.1] [0.2] [0.3]在 csv 文件中。

4

1 回答 1

2

您可以就地减去(不复制数组):

dataFast -= np.median(newLists)
于 2013-06-08T16:24:01.167 回答