title: fit CountVectorizer on training and test data to not miss any words
body: <p>I have a training date set for which I know the labels for the classification and a test data set where I do not havve the labels.</p>
  <p>Now, I want to fit the Vectorizer to the union of the training and test reviews to not miss any words.</p>
  <p><a href="https://i.stack.imgur.com/FInqj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FInqj.png" alt="df with labels" /></a></p>
  <p><a href="https://i.stack.imgur.com/hDvJY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hDvJY.png" alt="df without labels" /></a></p>
  <pre><code>from sklearn.feature_extraction.text import CountVectorizer
  
                                                           #
  
  vectorizer = CountVectorizer(encoding='str', stop_words=&quot;english&quot;, analyzer='word')
  
  df_union=pd.concat([imdb_dataset_train,reviews_test])
  df_union = df_union['review']
  df_union.head()
  
  X=vectorizer.fit_transform(df_union['review'])
  
  X_train = ?
  X_test= ?
  </code></pre>
  <p>How could I merge the test and train data again such that
  <code>X_train.shape[1]==X_test.shape[1]</code> ?</p>