Skip to content
Advertisement

How to perform an operation between two rows at a different index, repeatedly

I have an excel file that can calculate the last column with a formula. I am trying to replicate this into python code. How can I perform an operation to achieve such results?

Essentially, the last column is supposed to take, for example, row 2 and subtract itself by row 0 (because they share the same industry besides the month, which I am trying to compare the two by).

I tried using a for loop and take the index of row i then subtract row i‘s ‘No. of jobs’ by the row i-2‘s ‘No. of jobs’ and adding that result to the last column. Then, I would increment i by 1 to let the operation continue for the next row, but I was unsuccessful.

JavaScript

Advertisement

Answer

Try as follows:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement