I have a dataframe in Python. I am looking for a way to calculate percentage change of a column based on the value of the first column of the table.
Number | Value
_____________________
1 1
1 1,5
1 1,5
1 3
2 300
2 200
2 250
2 350
... ...
This is how I would like the dataframe to look:
Number | Value | pct_change
___________________________________
1 1
1 1,5 0,5
1 1,5 0,0
1 3 1,0
2 300
2 200 -0,33
2 250 0,25
2 350 0,40
... ... ...