In this python pandas program, we will join the two Dataframes along rows using the pandas library.
Steps to solve the program
- Import pandas library as pd.
- Create two dataframes using pd.DataFrame().
- Join the dataframes using pd.concat().
- Print the output.
import pandas as pd
df1 = pd.DataFrame({'ID':[1,2,3],'Name':['Yash','Gaurav','Sanket'],
'Age':[30,27,28]})
df2 = pd.DataFrame({'ID':[4,3],'Name':['Tanmay','Athrva'],'Age':[26,22]})
result = pd.concat([df1,df2])
print("New dataframe")
print(result)
Output :
New dataframe
ID Name Age
0 1 Yash 30
1 2 Gaurav 27
2 3 Sanket 28
0 4 Tanmay 26
1 3 Athrva 22