def _aggr_mode(inList):
 valueCounts = dict()
 nonNone = 0
 for elem in inList:
  if (elem == SENTINEL_VALUE_FOR_MISSING_DATA):
   continue
  nonNone += 1
  if (elem in valueCounts):
   valueCounts[elem] += 1
  else:
   valueCounts[elem] = 1
 if (nonNone == 0):
  return None
 sortedCounts = valueCounts.items()
 sortedCounts.sort(cmp=(lambda x, y: (x[1] - y[1])), reverse=True)
 return sortedCounts[0][0]

def _aggr_mode ( inList ) : valueCounts = dict ( ) nonNone = 0 for elem in inList : if ( elem == SENTINEL_VALUE_FOR_MISSING_DATA ) : continue nonNone += 1 if ( elem in valueCounts ) : valueCounts [ elem ] += 1 else : valueCounts [ elem ] = 1 if ( nonNone == 0 ) : return None sortedCounts = valueCounts . items ( ) sortedCounts . sort ( cmp = ( lambda x , y : ( x [ 1 ] - y [ 1 ] ) ) , reverse = True ) return sortedCounts [ 0 ] [ 0 ]
returns most common value seen in the non-none elements of the list .