
The append() method in pandas helps us append two dataframes together.
Syntax –
df1.append(df2)
Examples –
Let’s create two dataframes –
import pandas as pd
data = {'Apple':[89, 89, 90, 110, 125, 84],
'Orange': [46, 46, 50, 65, 63, 48],
'Banana': [26, 30, 30, 25, 38, 22],
'Mango': [80, 80, 90, 125, 130, 150]}
index = ['Jan','Feb','Mar','Apr','May','June']
df1 = pd.DataFrame(data, index=index)
df1

data2 = {'Apple':[131, 123, 123, 140, 145, 145],
'Orange': [110, 120, 60, 42, 47, 62],
'Banana': [22, 36, 20, 27, 23, 34 ],
'Mango': [140, 140, 135, 135, 80, 90]}
index2 = ['Jul','Aug','Sep','Oct','Nov','Dec']
df2 = pd.DataFrame(data2, index=index2)
df2

1 . Append Two DataFrames together in Pandas –
To append the second dataframe to the first dataframe, we can use the append method in pandas.
df = df1.append(df2)
df
