To convert Python Pandas dataframe to NumPy array, we can use the to_numpy
method.
For instance, we write
df = pd.DataFrame(data={'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]},
index=['a', 'b', 'c'])
n = df.to_numpy()
to create the df
data frame with some data in it.
Then we call df.to_numpy
to return the df
data frame as a NumPy object.