I am going to standardized a vector layer field in Python console in QGIS, for that I want to get mean value and stdev value of the field.
How do I find mean and stdev in using PyQGIS.
I tried this. It is not working
layer=iface.activeLayer()
idx=layer.fields().indexFromName("mean")
ave = layer.meanValue(idx)
print (ave)
stdDev = layer.stdDevValue(idx)
print (stdDev)
QgsAggregateCalculator.meanandQgsAggregateCalculator.StDevrespectively. If that works for you, I'll close this question as a duplicate. – Germán Carrillo Sep 23 '21 at 03:49QgsAggregateCalculator.Mean(with a capital M). – Ben W Sep 23 '21 at 05:04