string - NumPy - Unpacking data with different dtypes from a file using genfromtxt -
I am trying to read in a file where the first column is a date string and 2-4 column regular floating point number Are there. If I get an array of 4x rows
data = np.genfromtxt ("infile.csv", delimiter = ','), In the file where all the values in column 1 are (quite right) NaNs then I tried to get my date as a string
data = np.genfromtxt ("infile.csv", Delimited = ',', dtype = ("| S20", float, float, float). The result is a 1D array with all the four columns of a row, which is now the array of arrays Is in the form of an element.
Can someone explain what I am doing wrong?
Better ways to do this, but since we do not know how quickly you handle date strings To plan (to write, not to run on the amount of data), and to use some loops in a dirty way: in the category for i (iN (data [0]) For i Data DataType = Tupl (NPMMTM (data), dtype = data.dtype [i]): For J, item in enumerate (line): data_tu [J] [i] = item
This will sleep a tuple with the data in each column.
Comments
Post a Comment