/WordClouds-Python

How to create a custom word cloud in Python

Primary LanguageJupyter Notebook

HOW TO CREATE A CUSTOM WORD CLOUD WITH TWITTER DATASET
By using Python and WordCloud library


A Word Cloud or Tag Cloud is a graphical representation of word frequency within a text: the more often a word is used in a text, the bigger and bolder it is represented in a graph. It can be a useful tool to communicate at a glance the most important keywords in a particular text or topic in a effective and fun way.

In this tutorial we will create a Word Cloud from a sample of nameless tweets extracted from Twitter for the period 3/16/2020 - 08/31/2020 in Peru. The dataset was modificated to respect Twitter private information policy and is used just as an example to show how to create a Word Cloud.

Table of contents

We will do different examples of Word Clouds by using the following steps:

  1. Install packages and import libraries
  2. Import the dataset, clean it up and select the text you are going to work with (tweets)
  3. Perform the text preprocessing and create a clean variable
  4. Create your Word Cloud:

    • Example 1: Default model

    • Example 2: Default model - customize parameters

    • Example 3: Customize shapes

    • Example 4: Customize colors - set multiple colors with a mask

    • Example 5: Customize colors - set a single color with a mask

    • Example 6: Customize colors - set multiple colors with a function

    • Example 7: Customize content - set repeated words
    • Example 8: Customize content - set non-repeated words

  5. Finally, you can review Bibliography to look for more information..