Pandas; how to concat two dataframes?

Submitted 7 months, 2 weeks ago
Ticket #439
Views 150
Language 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 7 months, 2 weeks ago


Wanna Post Ad?
Reach a large group of audience by posting an ad about your business here. For more details
Drop us a Message