追加两个具有相同列名的数据框。没有NaN值

时间:2018-12-11 20:39:12

标签: python pandas dataframe

两个数据框:

df1:

           zone_temp_1
Date/Time
15:36:20     73.500000
15:36:40     73.500000
15:37:00     73.400002
15:37:20     73.400002
15:37:40     73.400002
15:38:00     73.400002
15:38:20     73.500000

df2:

           zone_temp_1
Date/Time
15:38:40     73.500000
15:39:00     73.400002
15:39:20     73.400002
15:39:40     73.400002
15:40:00     73.400002

我希望连接看起来像这样:

           zone_temp_1
Date/Time
15:36:20     73.500000
15:36:40     73.500000
15:37:00     73.400002
15:37:20     73.400002
15:37:40     73.400002
15:38:00     73.400002
15:38:20     73.400002
15:39:20     73.500000
15:39:40     73.500000
15:40:00     73.400002

将pandas.concat用作“ df1 = pd.concat([df1,df2])”之类的东西

                   0  zone_temp_1
Date/Time
15:36:20   73.500000          NaN
15:36:40   73.500000          NaN
15:37:00   73.400002          NaN
15:37:20   73.400002          NaN
15:37:40   73.400002          NaN
15:38:00   73.400002          NaN
15:38:20   73.400002          NaN
15:38:40         NaN    73.500000
15:38:20         NaN    73.500000
15:39:00         NaN    73.400002
15:39:20         NaN    73.400002
15:39:40         NaN    73.400002
15:40:00         NaN    73.400002

这被标记为重复问题,但我已经尽职调查,找不到任何解决方案。

1 个答案:

答案 0 :(得分:0)

您可以进行bigdata = df1.append(df2, ignore_index=True)