def count(fields): return len([f for f in fields if f != None]) def sum_value(fields): return sum([f for f in fields if f != None]) def mean(fields): return None if count(fields) == 0 else float(sum_value(fields))/count(fields)
Pre-Logic Script Code: import numpy def mean(fields): return numpy.mean([f for f in fields if f != None]) Expression (selected field in ArcMap Table): mean([ !Index2006! , !Index2007! , !Index2008! , !Index2009! , !Index2010! , !Index2011! , !Index2012! ])
def mean(field1, field2, field3): fieldList = [field1, field2, field3] validList = [] for i in fieldList: if i != None: validList.append(i) meanVal = sum(validList)/len(validList) return meanVal
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.