WordCloud from data frame with frequency python

first we get list of tuples

tuples = [tuple(x) for x in df.values]

then

wordcloud = WordCloud().generate_from_frequencies(dict(tuples))

that's all


For me it worked creating a dictionary, like this:

d = {}
for a, x in bag.values:
    d[a] = x

import matplotlib.pyplot as plt
from wordcloud import WordCloud

wordcloud = WordCloud()
wordcloud.generate_from_frequencies(frequencies=d)
plt.figure()
plt.imshow(wordcloud, interpolation="bilinear")
plt.axis("off")
plt.show()

where bag is a pandas DataFrame with columns words and counts