I have csv file with [NEAR_DIST] (<-row 7). I would like to know how can I get the mean and STD of this array.
I used csv and numpy:
# -*- coding: utf-8 -*-
with open('C:\\test.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
distance = 
distance.append(float(x) for x in csvfile)
for row in readCSV:
distance = row
a = numpy.array(distance, dtype = 'float_')
b = numpy.sum(a)
The question is a little unclear. My assumption is that you have some data of the form:
and you want to find the sum of elements in the 7th column. i.e. 7 + 17 + 27 + ... in this example.
This should work:
import numpy data = numpy.genfromtxt("a.csv", delimiter=",") data[:, 6].sum() # 6 because indices start from 0 in python