Answers for "how to convert data frame to matrix in python"

4

data frame to matrix r

data.matrix(frame, rownames.force = NA)
Posted by: Guest on September-15-2020
0

Convert Dataframe to an array

import numpy as np
import pandas as pd
  
  
arr = np.random.rand(4, 3)
print("Numpy array:")
print(arr)
  
# convert numpy array to dataframe
df = pd.DataFrame(arr, columns =['A', 'B', 'C'])
print("nPandas DataFrame: ")
df
Posted by: Guest on August-25-2021

Code answers related to "how to convert data frame to matrix in python"

Browse Popular Code Answers by Language