Python Practice › Pandas Programs › Program 79

Join along rows

EasyPandas Programs · 79 of 95

Write a pandas program to join two DataFrames along rows.

Advertisement
Output
   Id     Name  Age
0   1     Yash   30
1   2   Gaurav   27
2   3   Sanket   28
3   4  Atharva   26
4   5   Tanmay   22

Approach

  1. pd.concat([d1, d2], ignore_index=True).

Solution

Python
import pandas as pdd1 = pd.DataFrame({"Id": [1, 2, 3], "Name": ["Yash", "Gaurav", "Sanket"], "Age": [30, 27, 28]})d2 = pd.DataFrame({"Id": [4, 5], "Name": ["Atharva", "Tanmay"], "Age": [26, 22]})print(pd.concat([d1, d2], ignore_index=True))
Output
   Id     Name  Age
0   1     Yash   30
1   2   Gaurav   27
2   3   Sanket   28
3   4  Atharva   26
4   5   Tanmay   22
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs