Pandas; how to concat two dataframes?

Submitted 2 years, 9 months ago
Ticket #439
Views 476
Language/Framework Python
Priority Low
Status In-Progress

df1 = pd.DataFrame({'Code':['1001','1002','1003','1004'],
          'Place':['Chile','Peru','Colombia','Argentina']})

 and

df2 = pd.DataFrame({'Code':['1001','1002','1003'],
          'Place':['Chile','Peru','Colombia']})

 How can i concat this two to make one DataFrame of two rows?

Submitted on Feb 14, 22
add a comment

1 Answer

check this,

import pandas as pd



df1 = pd.DataFrame({'Code':['1001','1002','1003','1004'],
          'Place':['Chile','Peru','Colombia','Argentina']})


df2 = pd.DataFrame({'Code':['1001','1002','1003'],
          'Place':['Chile','Peru','Colombia']})


joinData = pd.concat([df1, df2], ignore_index=True, sort=False)

print(joinData)

Submitted 2 years, 9 months ago


Latest Blogs