Append dataframes in pandas
<p>I have two dataframes in pandas
(copy from Spyder Variable Explorer)</p>

<p>df1</p>

<pre><code>index   0    1    2    3    4    5   6
0       Loc 0.0  0.0  0.0  0.25 0.0  light
1       Loc 0.0  0.0  0.0  0.25 0.0  light
2       Loc 0.0  0.0  0.0  0.25 0.0  light
3       Loc 0.0  0.0  0.0  0.25 0.0  light
</code></pre>

<p>df2</p>

<pre><code>index   0       1      2    3   4   5   6
0       DCos  -0.25  -0.2  0.9  nan nan nan
1       DCos  -0.25   0.2  0.9  nan nan nan
2       DCos   0.25  -0.2  0.9  nan nan nan
3       DCos   0.25   0.2  0.9  nan nan nan
</code></pre>

<p>I would like to append dataframe 2 to dataframe 1, to have</p>

<pre><code>index   0    1    2    3    4    5   6      7       8     9    10   11  12  13                                         
0       Loc 0.0  0.0  0.0  0.25 0.0  light  DCos  -0.25  -0.2  0.9  nan nan nan
1       Loc 0.0  0.0  0.0  0.25 0.0  light  DCos  -0.25   0.2  0.9  nan nan nan
2       Loc 0.0  0.0  0.0  0.25 0.0  light  DCos   0.25  -0.2  0.9  nan nan nan
3       Loc 0.0  0.0  0.0  0.25 0.0  light  DCos   0.25   0.2  0.9  nan nan nan
</code></pre>

<p>I have tried</p>

<pre><code>df1.join.(df2)
</code></pre>

<p>but df1 was not changed. I know there is an append function described in the documentation, but in only appends rows. Is there a way to append columns ?</p>

<p><strong>Disclaimer</strong>: I do not have 50 rep points to comment. So this answer is just a comment as <a href="http://stackoverflow.com/users/704848/edchum">EdChum</a> has given the correct answer.</p>

<p>You should take a look at the documentation of the various types of concat, merge and join <a href="http://pandas.pydata.org/pandas-docs/stable/merging.html#concatenating-objects" rel="nofollow">here</a>.</p>

<p>If your trying to concatenate the two dataframes using the index, you simply need:</p>

<pre><code>df3 = pd.concat([df1,df2], axis=1)
</code></pre>

<p>This will place the second dataframe(df2) next to the first one(df1) where the indexes match.</p>

<p>If you want to concatenate without being index-sensitive, try </p>

<pre><code>df3 = pd.concat([df1,df2], axis=1, ignore_index=True)
</code></pre>

python pandas formatting