title: TypeError: Image data cannot be converted to float on wordcloud project
body: <p>So we have this code practice to create a word cloud, seems very simple since its just creating a dictionary...but somehow the code they provided to execute the word cloud is giving me an error of </p>
  
  <pre><code>"TypeError: Image data cannot be converted to float". 
  </code></pre>
  
  <p>I've checked the very same text file used on my own computer just to generate the dictionary and corroborated that the values are indeed integers so I'm stuck. Posting all code provided here below:</p>
  
  <pre><code>!pip install wordcloud
  !pip install fileupload
  !pip install ipywidgets
  !jupyter nbextension install --py --user fileupload
  !jupyter nbextension enable --py fileupload
  
  import wordcloud
  import numpy as np
  from matplotlib import pyplot as plt
  from IPython.display import display
  import fileupload
  import io
  import sys
  </code></pre>
  
  <h1>This is the uploader widget they gave us</h1>
  
  <pre><code>def _upload():
  
      _upload_widget = fileupload.FileUploadWidget()
  
      def _cb(change):
          global file_contents
          decoded = io.StringIO(change['owner'].data.decode('utf-8'))
          filename = change['owner'].filename
          print('Uploaded `{}` ({:.2f} kB)'.format(
              filename, len(decoded.read()) / 2 **10))
           file_contents = decoded.getvalue()
  
      _upload_widget.observe(_cb, names='data')
      display(_upload_widget)
  
  _upload()
  </code></pre>
  
  <h1>Here comes the code I wrote</h1>
  
  <pre><code>def calculate_frequencies(file_contents):
  # Here is a list of punctuations and uninteresting words you can use to process your text
      punctuations = '''!()-[]{};:'"\,&lt;&gt;./?@#$%^&amp;*_~'''
      uninteresting_words = ["the", "a", "to", "if", "is", "it", "of", "and", "or", "an", "as", "i", "me", "my", \
  "we", "our", "ours", "you", "your", "yours", "he", "she", "him", "his", "her", "hers", "its", "they", "them", \
  "their", "what", "which", "who", "whom", "this", "that", "am", "are", "was", "were", "be", "been", "being", \
  "have", "has", "had", "do", "does", "did", "but", "at", "by", "with", "from", "here", "when", "where", "how", \
  "all", "any", "both", "each", "few", "more", "some", "such", "no", "nor", "too", "very", "can", "will", "just"]
  
  # My Code
      frequencies = {}
      floatdic = {}
      case = file_contents.split()
      for word in case:
          words = word.strip(punctuations)
          lower = words.lower()
          if lower.isalpha() == False or lower in uninteresting_words:
              continue
          elif lower not in frequencies:
              frequencies[lower]= 0
          frequencies[lower]+=1
      return frequencies
      #Their Code Provided for wordcloud
      cloud = wordcloud.WordCloud()
      cloud.generate_from_frequencies(frequencies)
      cloud.to_file("myfile.jpg")
      return cloud.to_array()
  </code></pre>
  
  <h1>Then they give this code to execute the word cloud</h1>
  
  <pre><code>myimage = calculate_frequencies(file_contents)
  plt.imshow(myimage, interpolation = 'nearest')
  plt.axis('off')
  plt.show()
  </code></pre>
  
  <p>it crashes on the "plt.imshow" line.
  They run these code on a Jupyter notebook if that is of any help</p>