I am trying to plot water-level hydrogaphs for multiple wells. The data are in a text file with the first column a date in the format 'yyyymmdd'. In this particular case, there are 35 other columns with float numbers.
I have been trying to use genfromtxt, but I don’t want to have to define all 36 dtypes.
I tried dtype=None with converters, but then I get the message that the converter is locked and cannot be updated.
I’m surprised you can’t use
np.genfromtxtwith aconverterargument to transform your first column into either :np.datetime64object (as @DSM suggests, provided you have a version of numpy recent enough (>1.6.1))a
np.object, with aconverteras:converter={0:lambda d: datetime.datetime.strptime(d,"%Y%m%d")If you don’t want to define the
dtypeyourself, you could usedtype=None. It’s not that good of an idea, though, as this option is notably slower than giving an explicitdtype.But as the documentation tells you, you can use a tuple to define your
dtype, so something like:or
could work.