Convert Pandas DataFrame to Numpy arrayFor performing some high-level mathematical functions, we can convert Pandas DataFrame to numpy arrays. It uses the DataFrame.to_numpy() function. The DataFrame.to_numpy() function is applied on the DataFrame that returns the numpy ndarray. SyntaxParameters
It ensures that the returned value is not a view on another array. ReturnsIt returns the numpy.ndarray as an output. Example1Output array([[2, 4.0, Timestamp('2000-01-01 00:00:00')], [3, 5.8, Timestamp('2000-01-02 00:00:00')]], dtype=object) Example2Output DataFrame ---------- x y z 0 17 62 35 1 25 36 54 2 42 20 15 3 48 62 76 Numpy Array ---------- [[17 62 35] [25 36 54] [42 20 15] [48 62 76]] Next TopicConvert Pandas DataFrame to CSV |