1

I saw it in the 0.24.2 pandas documentation pandas.DataFrame.values that

Warning We recommend using DataFrame.to_numpy() instead.

Why is to_numpy() preferred over DataFrame.values? Can someone explain it in details?

I am asking this because I have probably written about hundreds of codes using DataFrame.values for converting a pandas DataFrame to numpy array thus far. If the underlying reason is serious, then I should probably go back to change everything with .values to to_numpy().

mathguy
  • 1,450
  • 1
  • 16
  • 33
  • this might be worth a read : https://stackoverflow.com/questions/13187778/convert-pandas-dataframe-to-numpy-array/54508052#54508052 – anky May 19 '19 at 11:51
  • This is a relatively new feature that appeared in version 24. I think it aims to give more flexibility in the way you extract the data to `numpy ndarray`, espescially in term of `dtype`. Therefore pandas recommend to use it instead of `.values`. But I don't think you should worry, `.values` does not seem to be in deprecation so far! – boris May 19 '19 at 11:52

0 Answers0