image_output_1.png
import csv

import matplotlib.pyplot as plt   # for wordclouds & charts

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import csv
import gc
from pathlib import Path
columns = ['tweetcreatedts', 'extractedts', 'userid', 'tweetid', 'text', 'language']
dataframe_collection = []
csvfile = '/kaggle/input/ukraine-russian-crisis-twitter-dataset-1-2-m-rows/UkraineCombinedTweetsDeduped_MAR14.csv.gzip'
df = pd.read_csv(csvfile, compression='gzip', index_col=0, encoding='utf-8', quoting=csv.QUOTE_ALL)
df = df[columns]

df = df[df['language'] == 'en']
df.reset_index(drop=True, inplace=True)
df.shape

tweet_string_list = df['bigram_text'].tolist()
tweet_string = ' '.join(tweet_string_list)

from wordcloud import WordCloud
wordcloud = WordCloud(width=2000, height=1334, random_state=1, background_color='black', colormap='Pastel1', max_words=75, collocations=False, normalize_plurals=False).generate(tweet_string)

# create the wordcloud
import matplotlib.pyplot as plt   # for wordclouds & charts
from matplotlib.pyplot import figure

# Define a function to plot word cloud
def plot_cloud(wordcloud):
    fig = plt.figure(figsize=(25, 17), dpi=80)
    plt.tight_layout(pad=0)
    plt.imshow(wordcloud)
    plt.axis("off")
    plt.box(False)
    plt.show()
    plt.close() 
   
#Plot
plot_cloud(wordcloud)    

tweet_string_list = df['trigram_text'].tolist()
tweet_string = ' '.join(tweet_string_list)

from wordcloud import WordCloud
wordcloud = WordCloud(width=2000, height=1334, random_state=1, background_color='black', colormap='Pastel1', max_words=50, collocations=False, normalize_plurals=False).generate(tweet_string)

plot_cloud(wordcloud)