1>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
2>>> df
3 A B
40 1 2
51 3 4
6>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'))
7>>> df.append(df2)
8 A B
90 1 2
101 3 4
110 5 6
121 7 8
13
1# Basic syntax:
2import pandas as pd
3appended_dataframe = dataframe_1.append(dataframe_2)
4# or:
5appended_dataframe = pd.concat([dataframe_1, dataframe_2])
6
7# Example usage:
8dataframe_1 = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
9dataframe_2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'))
10appended_dataframe = dataframe_1.append(dataframe_2)
11print(appended_dataframe)
12 A B
130 1 2
141 3 4
150 5 6
161 7 8
17
18# Note, add "ignore_index = False" if you want new sequential row indices
19# Note, append does not modify the dataframes in place, which is why
20# running just dataframe_1.append(dataframe_2) doesn't change
21# dataframe_1
22# Note, if the column names aren't the same, the dataframes will be
23# appended with NaNs like:
24 A B C D
250 1.0 2.0 NaN NaN
261 3.0 4.0 NaN NaN
270 NaN NaN 5.0 6.0
281 NaN NaN 7.0 8.0
1>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
2>>> df
3 A B
40 1 2
51 3 4
6>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'))
7>>> df.append(df2)
8 A B
90 1 2
101 3 4
110 5 6
121 7 8