-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
Hi,
My group and I use the hashtags #MakeAmericaGreatAgain and #ImWithHer as a basis for our project. However, we would also like to see the other hashtags which the tweets have been using. To that end, we wrote a code that would insert a list of all hashtags used under a "All Hashtags" column for all tweets.
hu=[]
for i in range(len(data["results"])):
ho=[]
for d in data['results'][i]['entities']['hashtags']:
ho.append(str(d["text"]))
hu.append(ho)
df["Hashtag"].copy()[0]=hu[0]
We were wondering the following:
-
How can we easily count the number of times the different hashtags have been used? We tried
df["Hashtag"].value_counts()but that counts the number of times specific lists occur rather than the elements in them. I guess we could do a loop but I'd hope for a more elegant solution. -
Is there a way to write the general code in a more 'smooth' way? And should we even use lists in the way we have done?
Thank you!
Metadata
Metadata
Assignees
Labels
No labels