PANDAS-使用第二个DataFrame作为该函数的输入,在列上应用功能?
寻找最快,最pandas
以以下方式进行以下方式:
support=
Values Confidence R/S
10 3 S
20 6 S
40 10 S
35 12 S
df =
name strike
xyz 12
dfg 6
ghf 40
目标:从支持
到df
的最接近0行。
挖掘输出:
df =
name strike support
xyz 12 [10, 3, S, 2]
dfg 6 [0, 0, S, 0] # as there is no > 0 value when subtracting strike from support
ghf 40 [35, 12, S, 5]
奖金:将列扩展到相关的列中。
我可以通过进行罢工来做到这一点,想知道是否有更好/更快的方法来实现我在想做的事情。
Look for the fastest and most pandas
centric way of doing the following:
support=
Values Confidence R/S
10 3 S
20 6 S
40 10 S
35 12 S
df =
name strike
xyz 12
dfg 6
ghf 40
Aim: Get the closest greater than 0 row from support
to df
.
Excpected output:
df =
name strike support
xyz 12 [10, 3, S, 2]
dfg 6 [0, 0, S, 0] # as there is no > 0 value when subtracting strike from support
ghf 40 [35, 12, S, 5]
Bonus: expand the columns into the relevant columns.
I can do this by looping through the strikes, wondering if there is a better/faster way to achieve what I am thinking of doing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
输出:
Use
merge_asof
Output: