How to merge two dataframes side-by-side?

前端 未结 3 1675
耶瑟儿~
耶瑟儿~ 2020-11-30 09:47

is there a way to conveniently merge two data frames side by side?

both two data frames have 30 rows, they have different number of columns, say, df1 has 20 columns

3条回答
  •  北海茫月
    2020-11-30 10:27

    You can use the concat function for this (axis=1 is to concatenate as columns):

    pd.concat([df1, df2], axis=1)
    

    See the pandas docs on merging/concatenating: http://pandas.pydata.org/pandas-docs/stable/merging.html

提交回复
热议问题