Basically the title sums it up. I have created a dummy pandas.Series
object and looked up all these properties and methods. Documentation states that all of them except maybe pandas.array
return numpy.ndarray
objects. What is the difference then and when should I use one method or attribute or another? I've read that for example there is some difference between numpy.flatten()
and numpy.ravel()
, the former returns new array and the latter returns the view. It is the same with pandas
?
import pandas as pd
s = pd.Series(range(10))
s.ravel() # array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
s.to_numpy() # array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
s.values # array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
s.array # <PandasArray>