1

From pandas documentation, I found the function to_numpy https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_numpy.html But when I tried it(the same example as in the documentation), I have: 'DataFrame' object has no attribute 'to_numpy'.

Do you know from where could be the problem?

  • Welcome to stackoverflow. Please share a minimal reproducible example so we can help with your issue. See: https://stackoverflow.com/help/minimal-reproducible-example – ScootCork Jun 23 '20 at 12:59
  • `to_numpy()` was introduced in Pandas 0.24. On earlier versions, you need to call `df.values`. – sjw Jun 23 '20 at 13:06
  • What version of pandas are you using? – NYC Coder Jun 23 '20 at 13:10

1 Answers1

2

The attribute to_numpy() was released with pandas version 0.24.0. Please upgrade your pandas package to use this attribute.

To check the version of pandas within your IDE:

import pandas
print(pandas.__version__)

You may refer this link for upgrading pandas.

Ruben Helsloot
  • 12,582
  • 6
  • 26
  • 49
Chandan
  • 430
  • 6
  • 9