I am using Python to do some calculation on a data series. The goal of the calculation is to remove the top 5 percentile data from the series. As an acceptance criteria, the manual calculation in excel is done in parallel. I need to meet the manual calculation results to get my code passed.
However, the results from Python and Excel are different from one another.
I've excluded lots of elements and finally narrowed down to the percentile function.
In Python, I do the percentile calculation (for the 5th percentile) as following:
import numpy as np
return np.percentile(values, percentile)
and in Excel, I used:
=PERCENTILE.INC(E8:E143, 0.05)
where the values
is the same as E8:E143
.
Could anyone explain the difference between these functions? And if possible, please list out the equations.
Many thanks.
==========================================================
UPDATE:
The percentile
used in the Python code is 5.0.