avibrazil
avibrazil

Reputation: 331

Concatenate Pandas dataframes with different set of columns

df1 has columns A, B, C, D, E

df2 has columns A, B, D

How to concatenate them in order to have a resulting dataframe that has rows of df1 and df2, values of A, B and D will be extended from df2 on df1, and columns C and E will be filled with NaN because df2 has no data for them?

Upvotes: 0

Views: 51

Answers (1)

SaulVP
SaulVP

Reputation: 90

There is a function called concat

pd.concat([df1,df2])

The input must be a iterable, so put them into a list ;)

Upvotes: 1

Related Questions