Feb-05-2021, 10:20 AM
Hello , please can you help me with merge. i tried find anything in forum but i did not find it.
i have two dataframes and i would like to merge them. df1 and df2 have the same number of rows.
car bus
0 1 8
1 9 5
2 1 8
3 2 8
4 3 8
5 6 5
pay
300 1
345 2
854 8
12 9
69 10
I would like to this
car bus pay
0 1 8 1
1 9 5 2
2 1 8 8
3 2 8 9
4 3 8 10
5 6 5 NA
i tried
df= pd.concat([df1,df2], axis=1)
df=do.call("merge", c(lapply(list(df1, df2), data.frame, row.names=NULL), by = 0, all = TRUE))[-1]
df=pd.merge(df1,df2,by = 0, all = TRUE)[-1]
but it did not work. Can you help me .thank you
i have two dataframes and i would like to merge them. df1 and df2 have the same number of rows.
car bus
0 1 8
1 9 5
2 1 8
3 2 8
4 3 8
5 6 5
pay
300 1
345 2
854 8
12 9
69 10
I would like to this
car bus pay
0 1 8 1
1 9 5 2
2 1 8 8
3 2 8 9
4 3 8 10
5 6 5 NA
i tried
df= pd.concat([df1,df2], axis=1)
df=do.call("merge", c(lapply(list(df1, df2), data.frame, row.names=NULL), by = 0, all = TRUE))[-1]
df=pd.merge(df1,df2,by = 0, all = TRUE)[-1]
but it did not work. Can you help me .thank you