Skip to content Skip to sidebar Skip to footer

How To Load Data From Csv Into Numpy Array Using Pandas

I want to load csv rows into a numpy array using pandas library. I can read the csv using pandas but havent found any function that allows reading row by row in csv file. How do I

Solution 1:

First convert to numpy array by values and then ndarray.tolist:

print (df.values)
[[0 'A/5 21171' 7.25 nan 'S']
 [0 'PC 17599' 71.2833 'C85' 'C']]

print (df.values.tolist())
[[0, 'A/5 21171', 7.25, nan, 'S'], [0, 'PC 17599', 71.2833, 'C85', 'C']]

Post a Comment for "How To Load Data From Csv Into Numpy Array Using Pandas"