Skip to content

Instantly share code, notes, and snippets.

@astrotars
Created November 2, 2017 14:21
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 astrotars/45560a6a4587333a9a59e1acf78edd61 to your computer and use it in GitHub Desktop.
Save astrotars/45560a6a4587333a9a59e1acf78edd61 to your computer and use it in GitHub Desktop.
import re
def find_hastags(text):
return re.findall(r'#(\w+)', text)
hashtags = []
#photos that I've recently liked
api.getLikedMedia()
result = api.LastJson
for r in tqdm(result['items']):
if r['caption'] is not None:
hashtag = find_hastags(r['caption']['text'])
#photos that i have been recently tagged in
api.getSelfUserTags()
result = api.LastJson
for r in result['items']:
if r['caption'] is not None:
hashtag = find_hastags(r['caption']['text'])
[hashtags.append(i.lower()) for i in hashtag]
top_hashtags = pd.Series(hashtags).value_counts()[:10]
print(top_hashtags.index)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment