Hello. Welcome back. In this segment, we are going to do some text analysis, specifically sentiment analysis. We're going to take a look at just text column of Elon Musk tweets, and take a look and see what's the tone of those. Is that more positive, more negative? To do that, we're going to use a library called TextBlob, which is a pandas library. It does lots of things besides sentiment analysis, but we're only going to take a look at that, at the moment. So let's begin. First, I'm going to go ahead and import the library, and then I'm going to create a new column called sentiment, where I'm basically passing the text of the just text into the text blob, and grabbing the sentiment back out. The bracket 0 here basically just extract the value of that sentiment back, so we can take a look at that. So we'll go ahead and run that. Now that's done, let's go ahead and take a look at our IAM Tweet table. Okay. So now we have a new sentiment column. Just a little grounding for that sentiment column. It goes from minus one to positive one. So zero would be neutral, positive one would be very positive, negative one would be very negative in terms of overall sentiment. So let's go through and take a look. Let's query our IAM Tweet table, and look for sentiments where we're greater than, or equal to zero. Meaning we're going to throw the neutral category into the positive for a second, and then we're going to order by sentiment descending, so we can see which are the most positive. All right, taking a look at that, we can see here we have a tweet not from us, but it's awesome. About to do chocolate egg hunt with all the kids, Candy Bonanza, happy Easter. Best to get it, because you can power your house and also drive. So you can tell the overall sentiment there, all the way down to neutral just a simple yes. All right. Let's flip it. Let's take a look at everything that's less than 0.0. Meaning those things that are non-neutral going towards the negative side. Okay. Here we go. The internet is insane. Boring is what we do. We don't think our product will be the cause of any wildfires, but the Boring company is donating $10,000, traffics drive me nuts. I'm going to build a tunnel boring machine and just start digging. Okay. So a few interesting things here. Yes, boring is a word that's negative. Boring is what we do here. I think is really referring to the Boring company. If you haven't taken a look at that, they do not boring stuff at all. But here we also have a connotation flip, where he's talking about boring as in boring a tunnel, but the Library is picking that up as a negative. So something to just keep in mind is that, depending on the libraries you're using and how you're taking a look at that sentiment, you're going to want to take a look at samples to make sure that it's giving you what you expect. For our purposes this is fine. We're wanting to take a look at the overall tone of Elon Musk tweets at large. So let's take a look at that. We're going to do a quick histogram of just the sentiment column, and this will give us what the sentiment looks like across all time for all of his tweets. So we have our central tendency, our mean is slightly right of center. Which means it's slightly more positive in general. So that's good for our hypothesis. But let's break that down a little bit. I want to see what it looks like year by year. So if you recall in an earlier segment when we were taking a look at themes, we built some tables that were specific for each year, so we're going to access those tables again. I'm just going to use a loop to go through each one of those tables just to build me a string, and then create a histogram of just that table that we did before, but just an easy way. So we're going to do the same thing we did here, but for each of those tables. So let's go through and execute that. Okay. So here we have 2011. You can also tell the number of tweets if you recall. As we go through time, you see more and more tweets. But what I'm trying to look for here is really where the mean is, and where it's shifting. So here we're in the zero space. Here we shift a little bit more. We've got a high bar at zero. But we're more on the positive, here this is more of a normal distribution looking as we go into 13, 14. If I keep paging through, I can see the overall mean of these distributions shifting more towards the positive, which is what our overall is. So what I'm going to walk away with here, because our hypothesis was really talking about this general tone would be more positive. I'm seeing that in the data, and our reasons for believing that at first were around the fact that, he's a visionary and he was thinking about creating new things in the future, etc. I think that as time goes on, his progress and success in that help contribute to the positivity of his tweets. Okay. With that, we will leave you until next time.