numpy genfromtxt - how to detect bad int input values
问题 Here is a trivial example of a bad int value to numpy.genfromtxt . For some reason, I can't detect this bad value, as it's showing up as a valid int of -1. >>> bad = '''a,b 0,BAD 1,2 3,4'''.splitlines() My input here has 2 columns of ints, named a and b. b has a bad value, where we have a string "BAD" instead of an integer. However, when I call genfromtxt , I cannot detect this bad value. >>> out = np.genfromtxt(bad, delimiter=',', dtype=(numpy.dtype('int64'), numpy.dtype('int64')), names