如何计算股票价格的天数高于另一天
我想获得(VZ)股票返回大于股票索引返回(INX)的天数,
我已经使用pct_change
函数计算了返回。现在,我想获得VZ的天数大于INX。我不知道该怎么做。
Dates VZ INX
2016-03-21 NaN NaN
2016-03-22 -0.004304 -0.000877
2016-03-23 -0.005638 -0.006386
2016-03-24 0.012285 -0.000378
2016-03-28 -0.002987 0.000545
2016-03-29 0.012172 0.008817
2016-03-30 -0.000185 0.004350
2016-03-31 0.000740 -0.002040
2016-04-01 -0.001294 0.00633
1
I would Like to get a count of the number of days for which (VZ) stock return is larger than the stock index return (INX)
I already calculated the return using the pct_change
function. Now I want to get the number of days VZ is larger than INX. I don't know how to go about this.
Dates VZ INX
2016-03-21 NaN NaN
2016-03-22 -0.004304 -0.000877
2016-03-23 -0.005638 -0.006386
2016-03-24 0.012285 -0.000378
2016-03-28 -0.002987 0.000545
2016-03-29 0.012172 0.008817
2016-03-30 -0.000185 0.004350
2016-03-31 0.000740 -0.002040
2016-04-01 -0.001294 0.00633
1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您可以检查使用列操作的“ vz”值的次数高于“ inx”值,并获取输出之和:
To do this you can check which times the "VZ" value is higher than the "INX" value using a column operation, and get the sum of the output: