1import pandas as pd
2
3# First DataFrame
4df1 = pd.DataFrame({'id': ['A01', 'A02', 'A03', 'A04'],
5 'Name': ['ABC', 'PQR', 'DEF', 'GHI']})
6
7# Second DataFrame
8df2 = pd.DataFrame({'id': ['B05', 'B06', 'B07', 'B08'],
9 'Name': ['XYZ', 'TUV', 'MNO', 'JKL']})
10
11frames = [df1, df2]
12
13result = pd.concat(frames)
1>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
2>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'))
3>>> df.append(df2, ignore_index=True)
4 A B
50 1 2
61 3 4
72 5 6
83 7 8
1# Stack the DataFrames on top of each other
2vertical_stack = pd.concat([survey_sub, survey_sub_last10], axis=0)
3
4# Place the DataFrames side by side
5horizontal_stack = pd.concat([survey_sub, survey_sub_last10], axis=1)
6
1In [8]: df4 = pd.DataFrame({'B': ['B2', 'B3', 'B6', 'B7'],
2 ...: 'D': ['D2', 'D3', 'D6', 'D7'],
3 ...: 'F': ['F2', 'F3', 'F6', 'F7']},
4 ...: index=[2, 3, 6, 7])
5 ...:
6
7In [9]: result = pd.concat([df1, df4], axis=1, sort=False)
8