我有一个41列(和n行)的数据框。我想将另一个数据框添加到主数据框(作为新列)。应该添加到主数据框架的新数据框架可以具有不同的列数,但与主数据框架具有相同的行数。例如:
新数据框应为:
有什么功能吗?
答案 0 :(得分:0)
您好像标记了熊猫(pd),因此假设您正在使用它,则可以使用:
pd.merge('main data frame', 'second data frame', left_index=True)
答案 1 :(得分:0)
您可以使用pd.concat:
new_df = pd.concat([main_df,second_df], axis=1)