日期框的摘录可以如下所示(它当然要大得多):
Date1 Log1 Date2 Log2 Date3 Log3
Index
0 01.01.2000 1000 02.01.2000 2000 01.01.2000 3000
1 02.01.2000 1050 03.01.2000 1950 02.01.2000 3020
2 03.01.2000 1100 04.01.2000 2000 03.01.2000 3000
有没有一种快速对齐行的方法,使日期(这里是Date3
和{Date1
列中的日期相匹配吗?在
非常感谢
我假设您只希望在Date1中日期匹配时保留['Date2','Log2']和['Date3','Log3']的值。在
您可以将不同的列读入不同的数据帧并使用
merge
。然后筛选以仅保留Date1列不为null的行。在一个字典来表示你的数据,这只是一个方便的加载示例数据到dataframe。在
开始数据帧:
^{pr2}$这很简陋,但能起作用:
在这一点上,我认为这就是你所看到的逻辑:
但要恢复到期望的输出
使用} 的解决方案,最后将^{} 所有数据放在一起:
list comprehension
和^{相关问题 更多 >
编程相关推荐