Last active
June 16, 2021 15:54
-
-
Save kirshiyin89/069645eb6976b9367045fc9e15d1c7a1 to your computer and use it in GitHub Desktop.
Create word cloud without shape
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from wordcloud import WordCloud | |
import matplotlib.pyplot as plt | |
import csv | |
file_ob = open(r"feedback.csv") | |
# read the feedback file | |
reader_ob = csv.reader(file_ob) | |
reader_contents = list(reader_ob) | |
words = "" | |
for row in reader_contents : | |
for feedback in row : | |
words = words + " " + feedback | |
# build the WordCloud image | |
wordcloud = WordCloud(width = 800, height = 400, background_color ='orchid', colormap='Pastel1', random_state = 1, max_words = 20).generate(words) | |
# save the image | |
wordcloud.to_file("wordcloud.png") | |
# show the WordCloud image | |
plt.figure() | |
plt.imshow(wordcloud) | |
plt.axis("off") | |
plt.margins(x=0, y=0) | |
plt.tight_layout(pad = 0) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment