Python Pandas program to join the two Dataframes along rows

In this python pandas program, we will join the two Dataframes along rows using the pandas library.

Steps to solve the program
  1. Import pandas library as pd.
  2. Create two dataframes using pd.DataFrame().
  3. Join the dataframes using pd.concat().
  4. 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
				
			

extract only words from a column of a DataFrame

join the two Dataframes along columns

Leave a Comment