Folks, I'm trying to use `vectorize` on the following lambda function, taking a scalar as input, and output a 10-char string fnc = lambda x: datetime.date.fromordinal(x).strftime("%Y-%m-%d") I can't find a way to get an actual 'S10' chararray as output. OIn top of that, it seems that vectorize still uses the oldnumeric typecode: is this on purpose (and then which one), or just because it has been updated yet ? Here's what I tried so far. Any idea/comment (even a 'that can't work, forget it) more than welcome, as usual Thx P. ---------------------------------------------------------- x = array([719893,719894, 719895]) fnc(x[0])
'1972-01-01'
fnc(x[:2])
TypeError: only length-1 arrays can be converted to Python scalars (OK, that wasn't suppose to work)
vectorize(fnc)(x[:2])
array([, ], dtype='|S0') (not quite)
vectorize(fnc,otypes="S")(x[:2])
array([, ], dtype='|S0') (ditto)
vectorize(fnc,otypes="|S10")(x[:2])
ValueError: invalid typecode specified
asarray(vectorize(fnc)(newddatesordinal[:2]),dtype='|S10')
array([Ø6z«ª*, Ø6z«ª*], dtype='|S10')
participants (1)
-
Pierre GM