How to keep index when using pandas merge

I would like to merge two DataFrames, and keep the index from the first frame as the index on the merged dataset. However, when I do the merge, the resulting DataFrame has integer index. How can I specify that I want to keep the index from the left data frame?

    In [4]: a = pd.DataFrame({'col1': {'a': 1, 'b': 2, 'c': 3}, 
                              'to_merge_on': {'a': 1, 'b': 3, 'c': 4}})

    In [5]: b = pd.DataFrame({'col2': {0: 1, 1: 2, 2: 3}, 
                              'to_merge_on': {0: 1, 1: 3, 2: 5}})

    In [6]: a
    Out[6]:
       col1  to_merge_on
    a     1            1
    b     2            3
    c     3            4

    In [7]: b
    Out[7]:
       col2  to_merge_on
    0     1            1
    1     2            3
    2     3            5

    In [8]: a.merge(b, how='left')
    Out[8]:
       col1  to_merge_on  col2
    0     1            1   1.0
    1     2            3   2.0
    2     3            4   NaN

    In [9]: _.index
    Out[9]: Int64Index([0, 1, 2], dtype='int64')

EDIT: Switched to example code that can be easily reproduced

    In [5]: a.reset_index().merge(b, how="left").set_index('index')
    Out[5]:
           col1  to_merge_on  col2
    index
    a         1            1     1
    b         2            3     2
    c         3            4   NaN

Note: for some left merge operations you may end up with more rows if there are multiple matches between a and b and you will need to deduplicate (documentation for deduplication). This is why pandas does not keep the index for you.

From: stackoverflow.com/q/11976503