title: How to convert set to float or integer
body: <p>I am interested in plotting the unique values in an integer vector u against the number of times each of those unique values occurs in u, (i.e. the frequency distribution of unique values occurring in u).</p>
  
  <pre><code>import nltk
  from nltk.corpus import state_union
  from nltk.tokenize import PunktSentenceTokenizer,word_tokenize
  from nltk import FreqDist
  import matplotlib
  from matplotlib import pyplot as plt
  
  txtwrds=state_union.words('2006-GWBush.txt')
  vocab=set(w.lower() for w in txtwrds if w.isalpha())
  vocab=nltk.Text(vocab)
  fdist1=FreqDist(txtwrds)
  u=[]
  for w in vocab:
      u.append(fdist1[w])
  
  x=FreqDist(u)
  y=set(u)
  print(len(x),len(y))  #Gives same vector length for x and y
  plt.scatter(x,y)  #This is what throws the error
  plt.show()
  </code></pre>
  
  <p>As you can see in the last few lines of code, in order to get a new vector y of the unique values in u I run "y=set(u)."  And I assign "x=FreqDist(u)."  So far so good.  Problem comes when I try to plot x and y using matplotlib's "scatter."  I get "TypeError: float() argument must be a string or a number, not 'set'"</p>
  
  <p>The full traceback:</p>
  
  <pre><code>Traceback (most recent call last):
  File "C:/Python34/first_program.py", line 45, in &lt;module&gt;
  plt.scatter(x,y)
  File "C:\Python34\lib\site-packages\matplotlib\pyplot.py", line 3200, in scatter
  linewidths=linewidths, verts=verts, **kwargs)
  File "C:\Python34\lib\site-packages\matplotlib\axes\_axes.py", line 3674, in scatter
  self.add_collection(collection)
  File "C:\Python34\lib\site-packages\matplotlib\axes\_base.py", line 1477, in add_collection
  self.update_datalim(collection.get_datalim(self.transData))
  File "C:\Python34\lib\site-packages\matplotlib\collections.py", line 192, in get_datalim
  offsets = np.asanyarray(offsets, np.float_)
  File "C:\Python34\lib\site-packages\numpy\core\numeric.py", line 525, in asanyarray
  return array(a, dtype, copy=False, order=order, subok=True)
  TypeError: float() argument must be a string or a number, not 'set'
  </code></pre>
  
  <p>Attempts at converting y to integer or float (y=int(y),y=float(y)) meet with errors like this:</p>
  
  <pre><code>Traceback (most recent call last):
  File "C:/Python34/first_program.py", line 44, in &lt;module&gt;
  y=int(y)
  TypeError: int() argument must be a string, a bytes-like object or a number, not 'set'
  </code></pre>
  
  <p>FYI - I am using 32 bit python v3.4.3 on a Windows 7 64 bit machine.  (There are some nltk bugs arising with 64 bit python v3.5, so have to use the earlier version.)</p>