Now we can have those repeatable steps and run the function highlighted above over any of our existing columns. So far, we have created our bag of words and tokens, searched for emojis, counted those emojis, and created a table with the data frame. Creating A FunctionĪfter creating the lines we did independently, we want to create a function, which is nothing more than repeatable code. You can see that the diamond (diamond hands was a popular phrase for WallStreetBets) and the rocket are the top emojis used. Thus we counted each one of the items in that list and ended up with these emojis below, highlighted in the Out section. We turn it into a bag of words, then a list using tokenize, and finally count it using the counter. That’s because we’re applying the data frame function (highlighted in the In section below), which counts each emoji in a column and a row. Then we create a counter (highlighted in the In section below) of those different emojis resulting in a data frame. We’ll then do a list comprehension by saying that for each element in the list, if it’s in our tokens and it is an emoji, we want to return only the emoji as highlighted below. So we’ll eliminate this variable because we don’t need it by clicking on the scissors icon at the top left, highlighted in the previous image above. Now we have words in a list indicated by brackets which we can review and evaluate one by one to see if it’s an emoji. We can see from the results above that we no longer have the collection of words that we had when we joined those 10 sections. And because we want to tokenize it, we’ll type word_tokenize(a) at the bottom and click Run. Let’s go back to the line we made earlier and call that variable a, so we put a = at the beginning. ![]() The next step is to turn those words into tokens. But be sure to delete the Bow = part in the code because we already have that variable in the next line.Īfter that we click Run and what we get is the 10 body sections that are now in words. So let’s create another line and enter the code highlighted in the image below to join the first 10 body sections in our data set. Next, we’ll pre-process this data set into a bag of words without looking at each section. If it has na and is false, as highlighted above, we want to keep it. We’ll look at body sections that don’t have a comment. But we need to eliminate these rows and create what we call a bag of words. This data set will allow us to evaluate all the different rows inside it. Our data set is WallStreetBets in Reddit, and you can see below it has a head, title, id, and body section. We’ll also import Counter for counting and executing frequency analysis on our emojis. So we’ll bring in word tokenize, which allows us to look at each word and evaluate it from the Collections library. Next, we’ll use the natural language toolkit and conduct deep-level text analysis. If you don’t have these libraries in your Python environment, you need to install them before we can proceed. The first is pandas, our data manipulation library, and the second is emoji, which allows us to identify and decode emojis. Let’s go to the top of the notebook and bring in our needed libraries. So let’s review the code and each essential step in applying it to Power BI. The image above are the emojis we’ll use in this tutorial. ![]() □️□ Rainbow Flag is a fully-qualified emoji as part of Unicode 7.0 which was introduced in 2014, and was added to Emoji 4.0.We want to end up with a code we can easily apply to different data sets and environments, such as the Python Script Editor in Power BI. Whether you’re an ally, or a part of the community, another way to use the Rainbow Flag emoji is as a part of a name of a social media profile, for all to see! As such, it is sometimes known as the Bi Flag emoji when it’s used to represent the concerns of the bisexual community, or the Lesbian Flag emoji when it’s used to represent topics relevant to the lesbian community. The rainbow flag is used to symbolize the entire LGBT community. It is used to represent the LGBT (lesbian, gay, bisexual, and transgender) community, and is often seen in LGBT rights marches all around the world. This flag is an official symbol of all gay, bisexual, and transgender movements. Be proud of who you are! Wave the Rainbow Flag emoji across social media! This emoji is a colored illustration of the rainbow flag, a flag with six colors of the rainbow-orange, yellow, green, red, blue, and purple.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |