Conteúdo do Curso
Tweet Sentiment Analysis
Words Count
Now we would like to explore the most represented number in our DataFrame. For this reason we will create a collection where we will store the most frequent words and then, plot it.
Methods description
from collections import Counter; import nltk
: Imports the Counter class from the collections module and the nltk library;from nltk.corpus import stopwords
: Imports a list of common stopwords from NLTK;nltk.download("stopwords")
: Downloads the stopwords dataset from NLTK;def remove_stopword(x)
: This defines a function namedremove_stopword
that takes a listx
as input and returns a new list with stopwords removed;return [y for y in x if y not in stopwords.words("english")]
: This comprehension expression filters out stopwords from the input listx
using the list of English stopwords from NLTK;Counter
: A class from the collections module used to count occurrences of elements in a list or iterable;stopwords.words("english")
: A method from NLTK that returns a list of stopwords for the English language;temp.most_common(25)
: Returns the 25 most common elements (words) and their counts from the Counter objecttemp
;temp.iloc[1:,:]
: Indexes a DataFrametemp
to exclude the first row and select all columns;temp.style.background_gradient(...)
: Applies a background gradient style to a DataFrametemp
.
Tarefa
Create a collection to count word occurrences using the Counter
module:
- Remove stopwords from our tweets texts.
- Create a collection.
- Create a DataFrame with the newly created list.
- Change the background color to
"Blues"
.
Mark tasks as Completed
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?
Obrigado pelo seu feedback!
Now we would like to explore the most represented number in our DataFrame. For this reason we will create a collection where we will store the most frequent words and then, plot it.
Methods description
from collections import Counter; import nltk
: Imports the Counter class from the collections module and the nltk library;from nltk.corpus import stopwords
: Imports a list of common stopwords from NLTK;nltk.download("stopwords")
: Downloads the stopwords dataset from NLTK;def remove_stopword(x)
: This defines a function namedremove_stopword
that takes a listx
as input and returns a new list with stopwords removed;return [y for y in x if y not in stopwords.words("english")]
: This comprehension expression filters out stopwords from the input listx
using the list of English stopwords from NLTK;Counter
: A class from the collections module used to count occurrences of elements in a list or iterable;stopwords.words("english")
: A method from NLTK that returns a list of stopwords for the English language;temp.most_common(25)
: Returns the 25 most common elements (words) and their counts from the Counter objecttemp
;temp.iloc[1:,:]
: Indexes a DataFrametemp
to exclude the first row and select all columns;temp.style.background_gradient(...)
: Applies a background gradient style to a DataFrametemp
.
Tarefa
Create a collection to count word occurrences using the Counter
module:
- Remove stopwords from our tweets texts.
- Create a collection.
- Create a DataFrame with the newly created list.
- Change the background color to
"Blues"
.
Mark tasks as Completed
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 1. Capítulo 8
AVAILABLE TO ULTIMATE ONLY