title: Getting words out of a numpy array of sentence strings
body: <p>I have a numpy array of sentences (strings) </p>
  
  <pre><code>arr = np.array(['It's the most wonderful time of the year.',
                 'With the kids jingle belling.',
                 'And everyone telling you be of good cheer.',
                 'It's the hap-happiest season of all.'])
  </code></pre>
  
  <p>(that I read from a csv file). I need to make a numpy array with all the unique words in these sentences.</p>
  
  <p>So what I need is </p>
  
  <pre><code>array(["It's", "the", "most", "wonderful", "time", "of" "year", "With", "the", "kids", "jingle", "belling" "and", "everyone", "telling", "you", "be", "good", "cheer", "It's", "hap-happiest", "season", "all"])
  </code></pre>
  
  <p>I could do this like</p>
  
  <pre><code>o = []
  for x in arr:
      o += x.split()
  words = np.array(o)
  unique_words = np.array(list(set(words.tolist())))
  </code></pre>
  
  <p>but as this involves first making lists and then converting <i>that</i> to numpy array, it's obviously gonna be slow and inefficient for large data.</p>
  
  <p>I also tried nltk as in</p>
  
  <pre><code>words = np.array([])
  for x in arr:
      words = np.append(words, nltk.word_tokenize(x))
  </code></pre>
  
  <p>but with this too seems inefficient as a new array is created on each iteration instead of the old one being modified. </p>
  
  <p>I suppose there's some elegant way of achieving what I want using more of numpy.</p>
  
  <p>Can you point me in the right direction?</p>