I am interested in knowing how to convert a pandas dataframe into a NumPy array.
dataframe:
import numpy as np import pandas as pd index = [1, 2, 3,
To convert a pandas dataframe (df) to a numpy ndarray, use this code:
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]])