如何计算股票价格的天数高于另一天

发布于 2025-01-18 03:45:50 字数 475 浏览 1 评论 0原文

我想获得(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耳根太软 2025-01-25 03:45:50

为此,您可以检查使用列操作的“ vz”值的次数高于“ inx”值,并获取输出之和:

temp = df["VZ"] > df["INX"]
print(temp.sum())

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:

temp = df["VZ"] > df["INX"]
print(temp.sum())
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文