0

I am trying to fix a data set using genfromtxt in Python 3.5. But I keep getting the next error:

ndtype = np.dtype(dict(formats=ndtype, names=names))
TypeError: data type not understood

This is the code I'm using. Any help will be appreciated!

names = ["country", "year"]
names.extend(["col%i" % (idx+1) for idx in range(682)])
dtype = "S64,i4" + ",".join(["f18" for idx in range(682)])

dataset = np.genfromtxt(data_file, dtype=dtype, names=names, delimiter=",",  skip_header=1, autostrip=2)
nanny
  • 57
  • 3
  • 9

1 Answers1

0

dtype = "S64,i4" + ",".join(["f18" for idx in range(682)])

is going to produce something like:

s64,i4f18,f18,f18,f18...

Note the lack of a comma after the i4.

jasonharper
  • 9,450
  • 2
  • 18
  • 42
  • I included the comma after i4, but still I'm getting the same error when I ran the next line of code where dataset is. Any other ideas? Thanks – nanny Dec 12 '16 at 20:11