Skip to content

Instantly share code, notes, and snippets.

@edsu
Created November 8, 2019 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edsu/4ee60128280d4d956c908bcc12540d46 to your computer and use it in GitHub Desktop.
Save edsu/4ee60128280d4d956c908bcc12540d46 to your computer and use it in GitHub Desktop.
import json
def get_hashtags(filename):
fh = open(filename)
tweets = json.load(fh)
hashtags = set()
for tweet in tweets:
if tweet['date'].startswith('2019'):
for hashtag in tweet['hashtags']:
hashtags.add(hashtag)
return hashtags
aoc = get_hashtags('aoc.json')
trump = get_hashtags('trump.json')
shared = aoc.intersection(trump)
print("@AOC used {} hashtags in 2019.".format(len(aoc)))
print("@realDonaldTrump used {} hashtags in 2019.".format(len(trump)))
print("They both used these hashtags {}".format(shared))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment