Pandas DataFrame Append

  • Post category:Pandas

In this Pandas tutorial, you will see the Pandas DataFrame append method in Python. You can easily append the Pandas DataFrame with the following code.

# import Pandas library
import pandas as pd

# create a dataframe
var = pd.DataFrame({'A': [5, 10, 15, 20], 'B': [25, 30, 35, 40], 'C': [45, 50, 55, 60]})

# create another dataframe
var2 = pd.DataFrame({'A': [50, 60, 70, 80], 'B': [90, 10, 20, 30], 'C': [40, 50, 60, 70]})

# append var2 to var
var = var.append(var2)

# display the dataframe after append
print(var)

Output:

    A   B   C
0   5  25  45
1  10  30  50
2  15  35  55
3  20  40  60
0  50  90  40
1  60  10  50
2  70  20  60
3  80  30  70

Free resources to learn advanced skills: AiHints and CodeAllow