Resolved: .values attribute of panda data frames return numpy array containing different types
Why does the .values attribute of panda data frames return numpy array containing different types (int, str)? see lending_co_data.values line. Thank you!
Hi Liezel!
Thanks for reaching out.
This is by construction, i.e. - how the creators of the .values attribute want this attribute to be appleid. .values
is an attribute that indeed returns a NumPy array.
Although you can still encounter .values
largely used in the pandas code worlwide, in today's version of pandas, its creators suggest that we use .to_numpy()
. In any case, using .values
isn't necessarily going to be erroneous in the code you will be writing.
Please visit the following links from the documentation for more information. Thank you.
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.values.html
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_numpy.html#pandas.DataFrame.to_numpy
Hope this helps.
Best,
Martin