Python: Inserting DataFrames into larger DataFrame at given index value
<p>I'm certain this is a trivial question but I cannot seem to find a solution. I have the following DataFrame: </p>

<pre><code>&gt;&gt;&gt; df = pd.DataFrame({'A': [1, 2, 3, 4, 5],
                    'B': [1, 2, 3, 4, 5],
                    'C': [1, 2, 3, 4, 5]})
&gt;&gt;&gt; df
   A  B  C
0  1  1  1
1  2  2  2
2  3  3  3
3  4  4  4
4  5  5  5
</code></pre>

<p>I also have some additional DataFrames (<code>df_a</code>, <code>df_b</code>) that I wish to insert into the the primary DataFrame (<code>df</code>). The additional DataFrames are saved to a dictionary with the key being the index of the row that I wish to insert the additional DataFrames after. </p>

<pre><code>df_a = pd.DataFrame({'A': ['X', 'Y'],
                    'B': ['X', 'Y'],
                    'C': ['X', 'Y']})

df_b = pd.DataFrame({'A': ['X', 'Y'],
                    'B': ['X', 'Y'],
                    'C': ['X', 'Y']})

idx_dict = {}
idx_dict[1] = df_a
idx_dict[3] = df_b 
</code></pre>

<p>The final result would resemble this:</p>

<pre><code>&gt;&gt;&gt; result
   A  B  C
0  1  1  1
1  2  2  2
0  X  X  X
1  Y  Y  Y
2  3  3  3
3  4  4  4
0  X  X  X
1  Y  Y  Y
4  5  5  5
</code></pre>

<p>I've read through the python <a href="http://pandas.pydata.org/pandas-docs/stable/merging.html" rel="nofollow noreferrer">concatenate</a> docs but can't seem to find out how to specify the particular location I wish to insert the DataFrame. Found a similar question <a href="https://stackoverflow.com/questions/20424932/concatenating-dataframes-by-index-columns-elements">here</a> but as my DataFrame indexes don't match this solution does not work for me.  </p>