sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
ssh-agent sh -c 'ssh-add; ssh-add -L'
DevSDK.pkg
DeveloperToolsCLI.pkg
MacOSX10.6.pkg
clang.pkg
llvm-gcc4.2.pkg
gcc4.2.pkg
# LEARNER CODE START HERE
file_c=""
for index, char in enumerate(file_contents):
if(char.isalpha()==True or char.isspace()):
file_c+=char
file_c=file_c.split()
file_w=[]
for word in file_c:
if word.lower() not in uninteresting_words and word.isalpha()==True:
file_w.append(word)
frequency={}
for word in file_w:
if word.lower() not in frequency:
frequency[word.lower()]=1
else:
frequency[word.lower()]+=1
#wordcloud
cloud = wordcloud.WordCloud()
cloud.generate_from_frequencies(frequency)
return cloud.to_array()
a,1
b,2
c,4
j,20
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
In [12]: d
Out[12]: {'a': '1', 'b': '2', 'c': '4', 'j': '20'}
$ pip install ai6
def generate_from_frequencies(self, frequencies, max_font_size=None):
"""Create a word_cloud from words and frequencies.
Parameters
----------
frequencies : dict from string to float
A contains words and associated frequency.
max_font_size : int
Use this font-size instead of self.max_font_size
Returns
-------
self
```python
So, I don't understand why is trowing me this error if I met the requirements of the function. I hope someone can help me, thanks.
**Note**
I work with worldcloud 1.3.1
import csv
from wordcloud import WordCloud
import matplotlib.pyplot as plt
reader = csv.reader(open('namesDFtoCSV', 'r',newline='\n'))
d = {}
for k,v in reader:
d[k] = int(v)
#Generating wordcloud. Relative scaling value is to adjust the importance of a frequency word.
#See documentation: https://github.com/amueller/word_cloud/blob/master/wordcloud/wordcloud.py
wordcloud = WordCloud(width=900,height=500, max_words=1628,relative_scaling=1,normalize_plurals=False).generate_from_frequencies(d)
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.show()