#100DaysOfCode in Python Transcripts
Chapter: Days 58-60: Twitter data analysis with Python
Lecture: Concepts: what did we learn
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Lets quickly summarize what we've learned so far
0:03
you can use Tweepy to interface with the Twitter API
0:07
always load API keys and secrets from your environment
0:11
and a way to do that is to use the os.environ.
0:14
Here's how you make a Tweepy API object, then
0:19
we can use that object to get our way to cursor
0:22
till you see we get all the tweets
0:24
from your timeline, then we did a top ten
0:25
of most popular tweets.
0:29
First we looked over all the tweets
0:33
and used sorted to get a written line down
0:35
to get the most popular tweets as defined by
0:38
an average of total likes and retweets per tweet
0:41
and voila.
0:43
I guess some marketing folks out there
0:46
will be interesting to know which tweets
0:47
are doing well, well you can and it's only
0:50
a few lines of code.
0:53
Next is most used hashtags and mentions.
0:56
What are we talking about the most,
0:57
so we define a couple of regular expressions
0:59
and put all the tweets in a big string
1:02
then we use find all in combination with calender
1:05
and we saw that before in the collections
1:07
and regex lessons.
1:08
To get to most common hashtags,
1:11
which were these, and similarly to get
1:15
the most mentioned Twitter handles,
1:17
which were those, very useful info.
1:20
Lastly, we made a Wordcloud of all the tweets
1:23
and we used the wordcloud module, we define
1:26
the mask which was our pilots logo,
1:30
added some stump words to get a better result
1:33
and constructed the word cloud object.
1:35
To get the Wordcloud to show in the notebook
1:38
we used a little bit of matte lot lip
1:42
and look at that, we got a word cloud
1:46
in the shape PyBites logo.
1:51
How cool is that right?
1:52
I mean visually its beautiful but
1:55
its also informative in that we really see
1:58
some words standing out.
2:00
Alright, with these practical examples
2:02
under your belt now its your turn
2:04
to go through, the practical exercises
2:07
we have lined up for you in Day 2 and 3.
2:09
Good luck.