Pandas:从包含字符串的列创建词云

Pandas: create word cloud from a column with strings

我有以下 dataframestring

  text
0 match of the day
1 euro 2016
2 wimbledon
3 euro 2016

如何从该列创建 word cloud

我认为你需要 with frequencies, so use value_countslist comprehension:

tuples = tuple([tuple(x) for x in df.text.value_counts().reset_index().values])
print (tuples)
(('euro 2016', 2), ('wimbledon', 1), ('match of the day', 1))

#
cloud.generate_from_frequencies(tuples)