You also need to add converters, for example:
from matplotlib.dates import strpdate2num ... np.loadtxt(s, delimiter=",", converters={0:strpdate2num('%m/%d/%Y'), 1:...}, dtype= ...
When numpy sees your dtype datetime format [64], it prepares the output of a column of type numpy.datetime64. numpy.datetim64 is a subclass of numpy.integer, and loadtxt is preparing to treat this column as an integer with the following:
def _getconv(dtype): typ = dtype.type if issubclass(typ, np.bool_): return lambda x: bool(int(x)) if issubclass(typ, np.uint64): return np.uint64 if issubclass(typ, np.int64): return np.int64 if issubclass(typ, np.integer): return lambda x: int(float(x)) ...
When it reaches the point of trying to convert on line 796 to numpyio:
items = [conv(val) for (conv, val) in zip(converters, vals)]
he is trying to use lambda x: int(float(x))
to handle input. When he does this, he tries to indicate the date (05/27/2007) on float and peters out. The strpdate2num conversion function above converts the date to a numeric representation.
source share