I need to calculate the difference(next row-current row) between two adjacent rows in a column. I saw the diff command, but it returns the opposite of what I need.
Lets say I have a dataframe like this
A B 0 a b 1 c d 2 e f 3 g h Required output: A B new 0 a b (c-a) 1 c d (e-c) 2 e f (g-e) 3 g h Nan
Thanks in advance!!
https://stackoverflow.com/questions/66057557/calculating-difference-between-two-adjacent-rows-in-python-dataframe February 05, 2021 at 12:24PM
没有评论:
发表评论