Q: How can I find the difference in two rows and divide this result by the sum of two rows? How can I find the difference in two rows and divide this result by the sum of two rows?
Here is how to do it in Excel.

Here is the formula I want to replicate, using Python.
=ABS(((B3-B2)/(B3+B2)/2)/((A3-A2)/(A3+A2)/2))

I know the difference can be calculated with df.diff(), but I can't figure out how to do the sum.
import pandas as pd
data = {'Price':[50,46],'Quantity':[3,6]}
df = pd.DataFrame(data)
print(df)


A: Basically you already have the diff then already you have two row sum 

Since diff :  x[2]-x[1] Then 'sum' : x[2]+x[1]=x[2]*2-(x[2]-x[1])

In your case the sum can be calculated by 
df*2-df.diff()
Out[714]: 
   Price  Quantity
0    NaN       NaN
1   96.0       9.0

So the output is 
(df.diff()/(df*2-df.diff())).eval('abs(Quantity/Price)')
Out[718]: 
0    NaN
1    8.0
dtype: float64


A: Can use rolling.sum with a window size of 2:
(df.diff()/df.rolling(2).sum()).eval('abs(Quantity/Price)')
0    NaN
1    8.0
dtype: float64


A: For small dataframes the use of .eval() is not efficient. 
The following is faster upto some 100.000 rows:
df = (df.diff() / df.rolling(2).sum()).div(2)
df['result'] = abs(df.Quantity / df.Price)
32.9 ms ± 1.05 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
vs.
39.6 ms ± 931 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
