Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def most_popular(read_tweet,date1,date2):
- popular=[]
- for candidate,tweets in read_tweet.items():
- match=True
- for x in tweets:
- if not (date1<=x[2]<=date2):
- match=False
- if match:
- for candidate in read_tweet:
- occur=0
- for x in read_tweet[candidate]:
- occur+= x[4]+ x[5]
- popular.append([occur,candidate])
- popular.sort(reverse=True)
- return [candidate for x, candidate in popular]
- #alternative way of doing the last part
- #for i,item in enumerate(popular):
- # mylist[i] = item[1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement