#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.
0:04 I mean, we tweet out a lot of stuff,
0:05 but what is the hashtag that we mention the most?
0:09 Let's define two regular expressions,
0:11 one for hashtag and one for mention.
0:14 And we covered regex more extensively in Day 28,
0:17 so you should be familiar with this syntax.
0:20 Then, I'm going to join all the tweets together
0:23 in one big string.
0:26 And if the mentions can be skewed
0:29 by having retweets in them, I'm going to define
0:31 another string with all the tweets excluding retweets.
0:39 Next, I'm going to use the find_all method,
0:41 which we also covered in Day 28, to get
0:44 all the hashtags.
0:49 Cool.
0:50 Then we can use the calendar, which we covered in Day 4,
0:53 in the collections module, to see the most common hashtags.
0:58 Look at that. Obviously we tweet a lot of about Python,
1:01 but also 100 Days of Code. And web frameworks like Django
1:05 and Flask. Oh yeah, Python and 100 Days of Code.
1:10 Let's look at the mentions.
1:15 Look at that.
1:16 Yeah, we really like the work @python_tip is doing
1:19 by tweeting out every day a Python tip or trick.
1:22 @PacktPub, we tweet out the new free e-book every day,
1:26 which is awesome. And of course, @TalkPython,
1:29 we really like the show and
1:31 all the stuff they put out there.
1:32 Then Bader, @RealPython, they have excellent articles,
1:34 etc. So this makes a lot of sense, and it's nice
1:38 to see this in numbers. Although the results are
1:41 definitely correct, I just want to show you how
1:45 the results are if I exclude the retweets.
1:47 So I can just copy this code,
1:52 and instead of "all tweets",
1:54 I'm going to call it on, "all tweets excluding retweets".
2:01 Yeah, that's more or less the same, but there are
2:04 some other users here that bubble up to the top.
2:08 So next up, you're going to make a Wordcloud of
2:10 all our tweets. And it's going to be awesome.