【发布时间】:2021-01-18 15:29:12
【问题描述】:
我有两个包含许多列 df1、df2 的数据框,我想用时间值相同的 df2 列中的数据替换所有 df1 值(时间列除外):
df1:
index time x y ......many other columns ( the same as df2)
0 1 1 1
1 1.1 2 2
2 1.1 3 3
3 1.1 4 4
4 1.4 5 5
5 1.5 6 6
6 1.5 7 7
df2:
index time x y ....many other columns (the same as df1)
0 1 10 10
1 1.1 11 11
2 1.2 12 12
3 1.3 13 13
4 1.4 14 14
5 1.5 15 15
6 1.6 16 16
the result for df1 should be:
index time x y ....many other columns
0 1 10 10
1 1.1 11 11
2 1.1 11 11
3 1.1 11 11
4 1.4 14 14
5 1.5 15 15
6 1.5 15 15
【问题讨论】:
-
您可以只连接两个数据框并删除第一个数据框列。