I have 3 columns in my df
How can i convert this to a matrix? I tried
numpy_matrix=df.as_matrix()
but this doenst give a matrix
I have 3 columns in my df
How can i convert this to a matrix? I tried
numpy_matrix=df.as_matrix()
but this doenst give a matrix
In pandas 0.24.0+, it is recommended that you use to_numpy
. The function as_matrix
was deprecated in pandas 0.23.0.
df.to_numpy()
To convert a pandas dataframe (df) to a numpy ndarray, use this code:
df = df.values
df now becomes the numpy ndarray: