How to use numpy.genfromtxt when first column is string and the remaining columns are numbers?

后端 未结 5 1131
说谎
说谎 2020-11-28 06:15

Basically, I have a bunch of data where the first column is a string (label) and the remaining columns are numeric values. I run the following:

data = numpy.         


        
5条回答
  •  孤城傲影
    2020-11-28 07:05

    You can use numpy.recfromcsv(filename): the types of each column will be automatically determined (as if you use np.genfromtxt() with dtype=None), and by default delimiter=",". It's basically a shortcut for np.genfromtxt(filename, delimiter=",", dtype=None) that Pierre GM pointed at in his answer.

提交回复
热议问题