我有以下数据帧:
dataPoint RIC ExpirationDate Exchange Description \
closingDate
2002-10-15 4207 SPH3 2003-03-20 CME:Index and Options Market
2002-10-15 5400 SPH4 2004-03-18 CME:Index and Options Market
2002-10-15 18661 SPM3 2003-06-19 CME:Index and Options Market
2002-10-15 19918 SPM4 2004-06-17 CME:Index and Options Market
2002-10-15 33439 SPU3 2003-09-18 CME:Index and Options Market
2002-10-15 35523 SPU4 2004-09-16 CME:Index and Options Market
2002-10-15 47733 SPZ2 2002-12-19 CME:Index and Options Market
2002-10-15 49022 SPZ3 2003-12-18 CME:Index and Options Market
我想获取ExpirationDate最接近closingDate的行(注意,静态closingDate存储在名为current_date的变量中)
iterrows()是我想到的一种解决方案,但它似乎效率低下。有没有一种最佳的方法来进行这种条件选择
找到最小绝对差的索引和索引
我在这里看到一个问题:如果索引值不是唯一的,那么您将需要在位置上索引,而不是标签。因此,我添加了
reset_index
调用相关问题 更多 >
编程相关推荐