Skip to content Skip to sidebar Skip to footer

Assign Columns Names To A Csv Dataset

I'm currently working on a dataset that consists of the following data: paper_id, word_attributes, class_label Now there are a total of 3700 word_attributes columns representing a

Solution 1:

You can perhaps read the csv file using:

a = np.genfromtxt(filename, delimiter=',', dtype=None, names=True)

it will create a numpy.recarray where each column can be called by a key, like a['paper_id']. When dtype=None, "the dtypes will be determined by the contents of each column, individually".


EDIT: as suggested by @askewchan, you have to pass names=True to keep the original names for the csv columns.

Post a Comment for "Assign Columns Names To A Csv Dataset"