Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def most_popular(read_tweet,date1,date2):
  2.     popular=[]
  3.     for candidate,tweets in read_tweet.items():
  4.         match=True
  5.         for x in tweets:
  6.             if not (date1<=x[2]<=date2):
  7.                 match=False
  8.         if match:
  9.             for candidate in read_tweet:
  10.                 occur=0
  11.                 for x in read_tweet[candidate]:
  12.                     occur+= x[4]+ x[5]
  13.                 popular.append([occur,candidate])
  14.     popular.sort(reverse=True)
  15.     return [candidate for x, candidate in popular]
  16.  
  17. #alternative way of doing the last part
  18. #for i,item in enumerate(popular):
  19. #    mylist[i] = item[1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement