将一行添加到数据框的底部

tacking a row onto the bottom of a dataframe

我有两个数据框:

DF1 = 14 行 x 49 列(美国)

DF2 = 1 行 x 49 列(美国各州)

我正在尝试将 DF2 添加到 DF1 的底部以创建:15 行 x 49 列

我已经尝试过 append() 和 concat(),它一直返回一个数据框,它是:15 行 x 98 列,除了第 15 行,第 50:98 列之外,所有这些都是 NaN。 ??

result = census_data.append(total_guns_2007)

这可能是因为列不同。

试试这个 -

total_guns_2007.columns = census_data.columns.values #this will make the column name same.
result = census_data.append(total_guns_2007)