Reputation: 21961
How do I stack the following 2 dataframes:
df1
hzdept_r hzdepb_r sandtotal_r
0 0 114 0
1 114 152 92.1
df2
hzdept_r hzdepb_r sandtotal_r
0 0 23 83.5
1 23 152 45
to give the following result:
hzdept_r hzdepb_r sandtotal_r
0 0 114 0
1 114 152 92.1
2 0 23 83.5
3 23 152 45
Using the pandas merge operations does not work since it just lines the dataframes horizontally (and not vertically, which is what I want)
Upvotes: 44
Views: 45031
Reputation: 6253
In [5]: a = pd.DataFrame(data=np.random.randint(0,100,(2,5)),columns=list('ABCDE'))
In [6]: b = pd.DataFrame(data=np.random.randint(0,100,(2,5)),columns=list('ABCDE'))
In [7]: c = pd.concat([a,b],ignore_index=True)
In [8]: c
Out[8]:
A B C D E
0 12 56 62 35 20
1 10 71 63 0 70
2 61 72 29 10 71
3 88 82 39 73 94
Upvotes: 70