code: def recategorize(self, new_categories):
          '''
          Parameters
          ----------
          new_categories : array like
          String names of new categories. Length should be equal to number of documents
  
          Returns
          -------
          TermDocMatrix
          '''
          assert len(new_categories) == self.get_num_docs()
  
          new_category_idx_store = IndexStoreFromList.build(set(new_categories))
          new_y = np.array(new_category_idx_store.getidxstrictbatch(new_categories))
  
          new_tdm = self._make_new_term_doc_matrix(self._X, self._mX, new_y, self._term_idx_store, new_category_idx_store,
                                                   self._metadata_idx_store, new_y == new_y)
          return new_tdf recategorize(self, new_categories):
          '''
          Parameters
          ----------
          new_categories : array like
          String names of new categories. Length should be equal to number of documents
  
          Returns
          -------
          TermDocMatrix
          '''
          assert len(new_categories) == self.get_num_docs()
  
          new_category_idx_store = IndexStoreFromList.build(set(new_categories))
          new_y = np.array(new_category_idx_store.getidxstrictbatch(new_categories))
  
          new_tdm = self._make_new_term_doc_matrix(self._X, self._mX, new_y, self._term_idx_store, new_category_idx_store,
                                                   self._metadata_idx_store, new_y == new_y)
          return new_tdm
docs: Parameters
          ----------
          new_categories : array like
          String names of new categories. Length should be equal to number of documents
  
          Returns
          -------
          TermDocMatrix