10 Minutes to Pandas tutorial - to_numpy() does not exist?
To check your version of pandas
import pandas as pd
print(pd.__version__)
If it's not 0.24, you need to update pandas else you can use df.values
.
To upgrade pandas under Anaconda, grab Anaconda command prompt and type:
conda update pandas
To upgrade pandas under Python3
pip3 install --upgrade pandas
One really great thing with to_numpy()
method is the copy
parameter it provides:
npa=df.to_numpy() #editing npa will reflect in df
npa=to_numpy(copy=True) #editing npa will not affect the df
This feature was just added in Version 0.24.0, which was released a couple of days ago. If you haven't updated yet, the attribute doesn't exist! Once you update pandas the problem should resolve itself.
Try df.values
instead. This will have the same effect for versions of pandas prior to 0.24.0