# Buggy code
def fit(self, X, y=None):
    """Fit the model according to the given training data.

    Parameters
    ----------
    X : {iterable of :class:`~gensim.models.doc2vec.TaggedDocument`, iterable of list of str}
        A collection of tagged documents used for training the model.

    Returns
    -------
    :class:`~gensim.sklearn_api.d2vmodel.D2VTransformer`
        The trained model.

    """
    if isinstance(X[0], doc2vec.TaggedDocument):
        d2v_sentences = X
    else:
        d2v_sentences = [
            doc2vec.TaggedDocument(words, [i]) for i, words in enumerate(X)
        ]
    self.gensim_model = models.Doc2Vec(
        documents=d2v_sentences,
        dm_mean=self.dm_mean,
        dm=self.dm,
        dbow_words=self.dbow_words,
        dm_concat=self.dm_concat,
        dm_tag_count=self.dm_tag_count,
        docvecs=self.docvecs,
        docvecs_mapfile=self.docvecs_mapfile,
        comment=self.comment,
        trim_rule=self.trim_rule,
        vector_size=self.size,
        alpha=self.alpha,
        window=self.window,
        min_count=self.min_count,
        max_vocab_size=self.max_vocab_size,
        sample=self.sample,
        seed=self.seed,
        workers=self.workers,
        min_alpha=self.min_alpha,
        hs=self.hs,
        negative=self.negative,
        cbow_mean=self.cbow_mean,
        hashfxn=self.hashfxn,
        epochs=self.iter,
        sorted_vocab=self.sorted_vocab,
        batch_words=self.batch_words,
    )
    return self


# Traceback (KeyError)
﻿Traceback (most recent call last):
File "main.py", line 9, in <module>
transformer.fit(series)
File "venv/lib/python3.7/site-packages/gensim/sklearn_api/d2vmodel.py", line 162, in fit
if isinstance(X[0], doc2vec.TaggedDocument):
File "venv/lib/python3.7/site-packages/pandas/core/series.py", line 868, in __getitem__
result = self.index.get_value(self, key)
File "venv/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 4375, in get_value
tz=getattr(series.dtype, 'tz', None))
File "pandas/_libs/index.pyx", line 81, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 89, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 987, in pandas._libs.hashtable.Int64HashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 993, in pandas._libs.hashtable.Int64HashTable.get_item
KeyError: 0

# Fixed code
def fit(self, X, y=None):
    """Fit the model according to the given training data.

    Parameters
    ----------
    X : {iterable of :class:`~gensim.models.doc2vec.TaggedDocument`, iterable of list of str}
        A collection of tagged documents used for training the model.

    Returns
    -------
    :class:`~gensim.sklearn_api.d2vmodel.D2VTransformer`
        The trained model.

    """
    if isinstance([i for i in X[:1]][0], doc2vec.TaggedDocument):
        d2v_sentences = X
    else:
        d2v_sentences = [
            doc2vec.TaggedDocument(words, [i]) for i, words in enumerate(X)
        ]
    self.gensim_model = models.Doc2Vec(
        documents=d2v_sentences,
        dm_mean=self.dm_mean,
        dm=self.dm,
        dbow_words=self.dbow_words,
        dm_concat=self.dm_concat,
        dm_tag_count=self.dm_tag_count,
        docvecs=self.docvecs,
        docvecs_mapfile=self.docvecs_mapfile,
        comment=self.comment,
        trim_rule=self.trim_rule,
        vector_size=self.size,
        alpha=self.alpha,
        window=self.window,
        min_count=self.min_count,
        max_vocab_size=self.max_vocab_size,
        sample=self.sample,
        seed=self.seed,
        workers=self.workers,
        min_alpha=self.min_alpha,
        hs=self.hs,
        negative=self.negative,
        cbow_mean=self.cbow_mean,
        hashfxn=self.hashfxn,
        epochs=self.iter,
        sorted_vocab=self.sorted_vocab,
        batch_words=self.batch_words,
    )
    return self