text_html_output_1.png text_plain_output_1.png
from PIL import Image

from wordcloud import WordCloud,STOPWORDS,ImageColorGenerator

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

df = pd.read_csv('../input/idcyberbullying/id-cyberbullying-instagram.tsv', sep='\t', encoding='ISO-8859-1')
df

df.label.value_counts()

analysis_df = df[['text', 'label']]

comment_len = pd.Series([len(comment.split()) for comment in df['text']])

df['Length'] = df.text.str.split().apply(len)

df['Length'] = df.text.str.split().apply(len)

from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator
from PIL import Image
def create_wordcloud(text, path):
    stopwords = set(STOPWORDS)
    wc = WordCloud(background_color='white', max_words=3000, stopwords=stopwords, random_state=42, width=900, height=500, repeat=True)
    wc.generate(str(text))
    wc.to_file(path)
    print('Word Cloud Saved Successfully')
    path = path
    display(Image.open(path))
plt.figure(figsize=(16, 5), dpi=80)
create_wordcloud(analysis_df['text'].values, 'all.png')