python - 比较 Pandas 中不同行之间的值

标签 python python-2.7 pandas dataframe

我是pandas的新手,我正在尝试比较行之间的值,但没有运气。
我想找到RSI DOJI 行之间的差异100下一个
在这种情况下,52.157595 -45.430342 .
我该怎么办?
我玩了一下query()但我不知道自己在做什么...

                    Close   RSI       MOM   MACD        HAM  HMAN DOJI
20161125  10:13:00  69.87  52.157595 -0.21  0.011241    0     0   100
20161125  10:14:00  69.77  45.430342 -0.24  0.003785    0     0     0
20161125  10:15:00  69.77  45.430342 -0.10 -0.002099    0     0     0
20161125  10:16:00  69.83  49.924669 -0.02 -0.001899    0     0     0

最佳答案

尝试将 diffloc 结合使用

df.RSI.diff(-1).loc[df.DOJI.eq(100)]

20161125  10:13:00    6.727253
Name: RSI, dtype: float64

说明
希望 diff 是不言自明的。但是,-1 将索引与当前行而不是下一行对齐。这意味着如果我用当 DOJI100 时的 bool 系列来掩盖它,那么我就有了答案。

关于python - 比较 Pandas 中不同行之间的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40834806/

相关文章:

python - 从Python中的ctype回调函数访问self?

.exe 中的 Python 子进程

python - 删除 pandas 中的中文

python - Google PubSub 消息重复

python - pandas 将时间序列转换为多列 DataFrame

python - 使用 python-gstreamer 播放 RTSP

python - 从列表中的字符串中删除有问题的字符

python - 合并字典列表,同时合并相似 ke 的值

python - 如何在 Pandas 中将嵌套列表转换为 DataFrame

Python 大学名称和缩写以及网络链接