I have a some dataframe object:
df.head()
A B C
0 7 7
1 3 6
2 5 5
3 2 7
4 4 3
I would like to compare for example A and B at n while also using C at n-1 to create a new row, so let's say D = An * Bn + Cn-1.
At first I used a generic python loop, but I quickly realized this was very slow with large datasets. Then I started looking at numpy vectorization (which is very fast) but I couldn't figure out a way to get previous entries.
What other alternatives do I have while keeping it nice and fast?