<jupyter_start><jupyter_text>Wordmap Create a wordmap with a particular shape: a hashtag wordmap<jupyter_code># requires a table in the following format

# index  tag              count
# 0      bonn             381
# 1      hofgarten        181
# 2      fridaysforfuture 113
# 3      unibonn          71

import pandas as pd
df = pd.read_excel("hashtag_count.xlsx")
# wordcloud generator requires a space-separated string 
# first create a list

dlist = []
for index, row in df.iterrows():
    print(row.tag)
    dlist = dlist + [str(row.tag)]*row["count"]  
from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator   
from PIL import Image  
import numpy as np  
import matplotlib.pyplot as plt  
from random import shuffle

# shuffle list and create string from list
shuffle(dlist)
words = ' '.join(dlist) 

stopwords=["bonn","hofgarten"] # define some stopwords if needed

mask = np.array(Image.open("ParkPNG/hofgarten.png")) # a png mask for wordmap shape
image_colors = ImageColorGenerator(mask) # take this png's colors
  
def wordmap(words, mask):  
    word_cloud = WordCloud(width = 1000, height = 1000,max_words=200,  
                           background_color='white', stopwords=stopwords,  
                           mask=mask).generate(words)  
    plt.figure(figsize=(10,8),facecolor = 'white', edgecolor='blue')  
    plt.imshow(word_cloud.recolor(color_func=image_colors)) 
    plt.axis('off')  
    plt.tight_layout(pad=0)  
    plt.savefig("Wordmaps/Hofgarten.png", format="png")  
    plt.show()  
       
wordmap(words, mask)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10025220680958385, 'fraction_numerical': 0.018915510718789406, 'mean_word_length': 3.1763157894736844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '448690', 'license': 'MIT', 'n_tokens_mistral': 542, 'n_tokens_neox': 501, 'n_words': 133, 'path': 'scripts/Wordcloud with particular shape.ipynb', 'repo_name': 'do-me/instagreens-bonn', 'size': '1586'}