I use this function to calculate percentile from here:
import numpy as np a = [12, 3, 45, 0, 45, 47, 109, 1, 0, 3] np.percentile(a, 25)
But I get this error :
AttributeError: 'module' object has no attribute 'percentile'
I also tried
import numpy.percentile as np
but it didn’t I got the same error.
my numpy version is 1.3.0 I tried to upgrade but it seems like it won’t I used :
[sudo pip install --upgrade scipy] but I found that there’s no upgrade.
my ubuntu version 9.10
my python version is : 2.6.4
i also tried to go arround the numpy.percentile module and I found this here:
>>> def percentile(N, P): ... n = int(round(P * len(N) + 0.5)) ... if n > 1: ... return N[n-2] ... else: ... return 0 ... >>> a = [1, 23, 5, 45, 676, 2, 0, 4,3] >>> a = sorted(a) >>> a [0, 1, 2, 3, 5, 4, 23, 45, 676] #When I call the function using >>> percentile(a,0.5) 3
but when I tried to find
0.5 percentile manually I found
Can anyone help explain to me why this is happening in any of those cases?
percentile function was added in version 1.5.x. You will need to upgrade to at least that version.
Did you try:
sudo pip install numpy==1.7.1 --upgrade
To check which version you are running, start the python console and run:
>>> import numpy >>> print numpy.__version__
You can also do:
sudo pip freeze | grep numpy
The Ubuntu 9.10 numpy package uses version 1.3.03. It is likely that installing version 1.7.0 vai pip was successful, but your machine is defaulting to the python-numpy version instead. You can remove by running:
sudo apt-get remove python-numpy