Skip to content

Instantly share code, notes, and snippets.

@kavichu
Created February 26, 2016 23:41
Show Gist options
  • Save kavichu/265e194993219cc8198b to your computer and use it in GitHub Desktop.
Save kavichu/265e194993219cc8198b to your computer and use it in GitHub Desktop.
ratings = [[3,4], [3,3,3,4], [4]]
def ratingThreshold(threshold, ratings):
avgF = lambda x: [ sum([ e for e in x[0] ]) / float(len(x[0])), x[1] ]
average = map(avgF, zip(ratings, range( len(ratings) ) ) )
return [i[1] for i in average if i[0] < threshold]
print(ratingThreshold(3.5, ratings))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment