merge two dataframes by row with same index pandas
<p>let's say i have the following two dataframes X1 and X2. I would like
to merge those 2 dataframes by row so that each index from each
dataframe being the same combines the corresponding rows from both
dataframes.</p>

<pre><code>       A  B C  D
DATE1 a1 b1 c1 d1

DATE2 a2 b2 c2 d2

DATE3 a3 b3 c3 d3


       A B  C  D
DATE1 f1 g1 h1 i1

DATE2 f2 g2 h2 i2

DATE3 f3 g3 h3 i3

how would i combine them to get


      A  B  C  D
DATE1 A1 B1 C1 D1
      f1 g1 h1 i1

DATE2 A2 B2 C2 D2
      f2 g2 h2 i2

DATE3 A3 B3 C3 D3
      f3 g3 h3 i3
</code></pre>

<p>I have tried this so far but this does not seem to work:</p>

<pre><code> d= pd.concat( { idx : [ X1[idx], X2[idx]]  for idx, value in appended_data1.iterrows() } , axis =1}
</code></pre>

<p>thanks</p>

<p>maybe this solution too could solve your problem:</p>

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

print df3
Out[42]: 
         A   B   C   D
DATE1  a1  b1  c1  d1
DATE1  f1  g1  h1  i1
DATE2  a2  b2  c2  d2
DATE2  f2  g2  h2  i2
DATE3  a3  b3  c3  d3
DATE3  f3  g3  h3  i3
</code></pre>

python pandas dataframe append concatenation