我正在try 使用pd.merge_asof
合并多个数据帧.
它们都包含两列,分别以datetime作为索引列和一个浮动值的变量列.它们的索引和时间不平衡,所以我必须将值标准化.
Date value1
2021-10-22 19:22:25 23.5
2021-10-22 19:22:40 23.4
2021-10-22 19:22:55 23.5
2021-10-22 19:30:12 23.6
2021-10-22 19:30:42 23.5
Date value2
2021-10-22 19:22:25 12
2021-10-22 19:22:40 12
2021-10-22 19:22:55 12
2021-10-22 19:30:12 16
2021-10-22 19:30:42 16
我可以成功地合并dfs,并使用
merged = pd.merge_asof(data_frames[0],data_frames[1], left_index=True,right_index=True,direction='nearest')
Date value1 value2
2021-10-22 19:22:25 23.5 12
2021-10-22 19:22:40 23.4 12
2021-10-22 19:22:55 23.5 12
2021-10-22 19:30:12 23.6 16
2021-10-22 19:30:42 23.5 16
现在我想做的是合并两个以上的数据帧.我试着这么做:
merged = pd.merge_asof(data_frames[0],data_frames[1],data_frames[2],left_index=True,right_index=True,direction='nearest')
但我得到了错误
pandas.errors.MergeError: Can only pass argument "on" OR "left_index" and "right_index", not a combination of both.
我不确定这表明了什么.我删除了其中一个索引参数,它仍然说了同样的话.我能得到我需要做的吗?
我希望能够在value2列的右边附加dataframe3,它有value3列.