#100DaysOfCode in Python Transcripts
Chapter: Days 58-60: Twitter data analysis with Python
Lecture: Most common hashtags and mentions
Login or purchase this course to watch this video and the rest of the course contents.
0:01 Next up are common hashtags and mentions. I mean, we tweet out a lot of stuff, but what is the hashtag that we mention the most?
0:10 Let's define two regular expressions, one for hashtag and one for mention. And we covered regex more extensively in Day 28,
0:18 so you should be familiar with this syntax. Then, I'm going to join all the tweets together in one big string. And if the mentions can be skewed
0:30 by having retweets in them, I'm going to define another string with all the tweets excluding retweets. Next, I'm going to use the find_all method,
0:42 which we also covered in Day 28, to get all the hashtags. Cool. Then we can use the calendar, which we covered in Day 4,
0:54 in the collections module, to see the most common hashtags. Look at that. Obviously we tweet a lot of about Python,
1:02 but also 100 Days of Code. And web frameworks like Django and Flask. Oh yeah, Python and 100 Days of Code. Let's look at the mentions. Look at that.
1:17 Yeah, we really like the work @Python_tip is doing by tweeting out every day a Python tip or trick.
1:23 @PacktPub, we tweet out the new free e-book every day, which is awesome. And of course, @TalkPython, we really like the show and
1:32 all the stuff they put out there. Then Bader, @RealPython, they have excellent articles, etc. So this makes a lot of sense, and it's nice
1:39 to see this in numbers. Although the results are definitely correct, I just want to show you how the results are if I exclude the retweets.
1:48 So I can just copy this code, and instead of "all tweets", I'm going to call it on, "all tweets excluding retweets".
2:02 Yeah, that's more or less the same, but there are some other users here that bubble up to the top. So next up, you're going to make a Wordcloud of
2:11 all our tweets. And it's going to be awesome.