Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2139 from nachouve/patch-1
[processing] Added "sum" field on StatisticsByCategories
  • Loading branch information
volaya committed Jun 15, 2015
2 parents 77c3e86 + cf5b454 commit 5d44de7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python/plugins/processing/algs/qgis/StatisticsByCategories.py
Expand Up @@ -81,11 +81,11 @@ def processAlgorithm(self, progress):
except:
pass

fields = ['category', 'min', 'max', 'mean', 'stddev', 'count']
fields = ['category', 'min', 'max', 'mean', 'stddev', 'sum', 'count']
writer = output.getTableWriter(fields)
for (cat, v) in values.items():
(min, max, mean, stddev) = calculateStats(v)
record = [cat, min, max, mean, stddev, len(v)]
(min, max, mean, stddev, sum) = calculateStats(v)
record = [cat, min, max, mean, stddev, sum, len(v)]
writer.addRecord(record)


Expand Down Expand Up @@ -115,4 +115,4 @@ def calculateStats(values):
else:
variance = 0
stddev = math.sqrt(variance)
return (minvalue, maxvalue, mean, stddev)
return (minvalue, maxvalue, mean, stddev, sum)

0 comments on commit 5d44de7

Please sign in to comment.