Average of Dataset Column

Continuing with this topic of conversation… Could someone help me modify my code to filter out certain values when running an average of a column? For example, I would like to exclude any values that are zero. I’m unsure on where to put the clause in this code.

for item in headers:
	avg = system.math.mean(map(float,dataIn.getColumnAsList(dataIn.getColumnIndex(item))))
	dataOut.append(avg)
newDS = system.dataset.toDataSet(headers, [dataOut])

avg = [val for val in map(float,dataIn.getColumnAsList(dataIn.getColumnIndex(item))) if val>0]

3 Likes