how to get array from dataframe code example
Example 1: dataframe from arrays python
import pandas as pd
df=pd.DataFrame({'col1':vect1,'col2':vect2})
Example 2: dataframe object to numpy array
import pandas as pd
df = pd.DataFrame(
[[21, 72, 67],
[23, 78, 69],
[32, 74, 56],
[52, 54, 76]],
columns=['a', 'b', 'c'])
arr = df.to_numpy()
print('\nNumpy Array\n----------\n', arr)
Example 3: list dataframe to numpy array
df.values
array([[nan, 0.2, nan],
[nan, nan, 0.5],
[nan, 0.2, 0.5],
[0.1, 0.2, nan],
[0.1, 0.2, 0.5],
[0.1, nan, 0.5],
[0.1, nan, nan]])