ynitSed
ynitSed

Reputation: 145

How to create a matrix from CSV in python?

Following this, I'd like to populate the matrix: (this is where I get stuck). I'd like to populate that matrix using like, data in the 4th column in that CSV file but wasn't able to. Was thinking of writing it to a output excel file.

    for i in readcsv:.........

However, everything (most things) that I do seem to go wrong.

Upvotes: 0

Views: 638

Answers (1)

ajoseps
ajoseps

Reputation: 2101

You can try and use panda, specifically this function, as_matrix(), to convert it to a matrix/array:

If you're completely new to panda, their tutorial is pretty good and doesn't take long!

You can read from a csv which will return a DataFrame. From that dataframe you can use the function, as_matrix(), I listed earlier.

Upvotes: 1

Related Questions