The 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
Answer from Nathan Villaescusa on Stack OverflowThe 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
Please upgrade your numpy package
pip install --upgrade numpy==1.19.1
or
sudo pip install --upgrade numpy==1.19.1
Check the version of your pandas library:
import pandas
print(pandas.__version__)
If your version is less than 0.24.1:
pip install --upgrade pandas
If you need your code to work with all versions of pandas, here's a simple way to convert a Series into a NumPy array:
import pandas as pd
import numpy as np
s = pd.Series([1.1, 2.3])
a = np.array(s)
print(a) # [1.1 2.3]
On an advanced note, if your Series has missing values (as NaN values), these can be converted to a masked array:
s = pd.Series([1.1, np.nan])
a = np.ma.masked_invalid(s)
print(a) # [1.1 --]
In relatively recent pandas version, 1.5.2, append works, but gives a warning.
In pd 2.0, append has been removed
https://pandas.pydata.org/docs/dev/whatsnew/v2.0.0.html#deprecations
In [14]: students_classes = pd.Series({'Alice': 'Physics',
...: 'Jack': 'Chemistry',
...: 'Molly': 'English',
...: 'Sam': 'History'})
...: kelly_classes = pd.Series(['Philosophy', 'Arts', 'Math'], index=['Kelly', 'Kelly', 'Kelly'])
In [15]: students_classes.append(kelly_classes)
C:\Users\paul\AppData\Local\Temp\ipykernel_6072\990183765.py:1: FutureWarning: The series.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
students_classes.append(kelly_classes)
Out[15]:
Alice Physics
Jack Chemistry
Molly English
Sam History
Kelly Philosophy
Kelly Arts
Kelly Math
dtype: object
Under the covers, append method uses _append, which works without raising the warning:
In [16]: students_classes._append(kelly_classes)
Out[16]:
Alice Physics
Jack Chemistry
Molly English
Sam History
Kelly Philosophy
Kelly Arts
Kelly Math
dtype: object
And using the recommended concat:
In [18]: pd.concat([students_classes,kelly_classes])
Out[18]:
Alice Physics
Jack Chemistry
Molly English
Sam History
Kelly Philosophy
Kelly Arts
Kelly Math
dtype: object
Python lists have an efficient append method. numpy has a np.append function which is a poorly named cover for calling np.concatenate, and is often misused (it shouldn't be used iteratively). pandas may be trying to avoid similar problems by getting rid of the append method. With pd.concat you can join many Series (or frames) at once, and aren't (as) tempted to use it in a loop.
Looking up the code for _append (which is still in 2.0), I see it ends up using pd.concat. So there's no value in using this 'work-around'. Use concat as recommended.
Probably an update of pandas may have changed the syntax, but you probably are looking for:
all_students_classes = students_classes._append(kelly_classes)
(quick tip, you can check the class definition in VS code by right cliking on the pd.Series and choosing Go to Definition, then you can see some of the methods defined at least). Otherwise use the concat method that uses this.