数据帧1:
index col1
03-05-2018 12:00:00 3
03-05-2018 13:00:00 4
03-05-2018 14:00:00 3
03-05-2018 15:00:00 3
....... ..
数据帧2
index col2
03-05-2018 12:00:00 1
03-05-2018 13:00:00 3
03-05-2018 13:30:00 4
03-05-2018 14:30:00 2
03-05-2018 15:00:00 3
..... ..
我要合并这些数据帧并删除索引不匹配的值:
数据帧3:
index col1 col2
03-05-2018 12:00:00 3 1
03-05-2018 13:00:00 4 3
03-05-2018 15:00:00 3 3
......... .. ..
有这样的函数吗pd.合并为了达到这个目的?(这是一个数据帧,索引是DateTime对象) 谢谢!你知道吗
编辑:我曾经pd.合并(dataFrame1,dataFrame2,how='inner',on='index',left\u index=True,right\u index=True)我得到了一个错误“Cannot compare type'Timestamp'with type'int”。我确信这两个索引都是时间戳
我只需要执行
inner
。inner
连接基本上是在on
值匹配时执行连接,否则is会删除它(出于这个问题的目的,会删除它)。你知道吗输出:
相关问题 更多 >
编程相关推荐