Skip to content

Instantly share code, notes, and snippets.

@astrotars
Created November 2, 2017 14:23
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/34c5b33a231fbd5f21473781670a670c to your computer and use it in GitHub Desktop.
Save astrotars/34c5b33a231fbd5f21473781670a670c to your computer and use it in GitHub Desktop.
interest_dict = {}
for tag in top_hashtags.index:
api.getHashtagFeed(tag)
result = api.LastJson
interest_dict[tag] = result
urls = []
num_likes = []
tags = []
for tag in interest_dict.keys():
items = interest_dict[tag]['items']
for i in items:
if 'image_versions2' in i:
urls.append(i['image_versions2']['candidates'][1]['url'])
num_likes.append(i['like_count'])
tags.append(tag)
df_tags = pd.DataFrame(
{'urls': urls,
'num_likes': num_likes,
'tag': tags
})
top_tags = df_tags.groupby('tag').max()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment