给定两个具有相同列的DataFrame.
DFA
Index Price 0 10.21 1 12.21
DFB
Index Price 0 10.21 1 10.24 2 11.32 3 12.21
I want to add a column to DFA with the times that each value appears in DFB, but with a tolerance of, let's say, 1%.
结果
Index Price Occurrences 0 10.21 2 1 12.21 1
是否仍有可能避免迭代?也许用merge_asof
和grouping
?
附注:这是对我的其他question条的修正,但发布了不同的威胁,因为它涉及的是一个略有不同的问题.