我試圖找到兩列中值的平均值。在列表中查找行數值的平均值
輸入:
tweetcricscore 34 #afgvssco 51
tweetcricscore 23 #afgvszim 46
tweetcricscore 24 #banvsire 12
tweetcricscore 456 #banvsned 46
tweetcricscore 653 #canvsnk 1
tweetcricscore 789 #cricket 178
tweetcricscore 625 #engvswi 46
tweetcricscore 86 #hkvssco 23
tweetcricscore 3 #indvsban 1
tweetcricscore 87 #sausvsvic 8
tweetcricscore 98 #wt20 56
我試圖找到col[1]
和col[3]
水平的平均值。即
34 + 51/2 = 42.5
代碼:
data = np.genfromtxt('keyword.csv', delimiter=',', comments=None)
d0=data[:,1]
d1=data[;,3]
,寫在同一輸入文件中col[4]
輸出d2
。
我可以找到許多垂直平均值計算的樣本,但無法找到水平。該數組不會被排序,因爲這兩個值相對於col[0]
和col[2].
彼此相關。任何建議表示讚賞。
在此先感謝。
你總是會有兩個靜態的列,你期待的平均水平?或者,那麼會有多少個列是動態的? – PyNoob
@pyNoob截至目前只有2列。不能保證未來。 –