Skip to content
Advertisement

put two columns from two different datasets together into one column

I have two dataframes

df1

name
Elias
David
Simon
Manuel

and a second df2

name
Gabriel
Brian
Simona
Danielle
Dilara
Martin
David
Simon

I one to put them into one column

I expecting an output like these:

name
Elias
David
Simon
Manuel
Gabriel
Brian
Simona
Danielle
Dilara
Martin

where every name occur once, so remove also duplicates.

i tried these

frames = [df1,df2]

but these gave me something different

Advertisement

Answer

Assuming the columns names are ‘A’ and ‘B’:

df3 = pd.concat([df1['A'], df2['B']], axis = 0).drop_duplicates().reset_index(drop=True)
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement