I still cannot find the question, but to get around it:
>>> a=[100,200,300]
>>> np.char.mod('%d', a)
array(['100', '200', '300'],
dtype='|S3')
This circumvents your problem:
>>> a=[100,200,3005]
>>> np.char.mod('%d', a)
array(['100', '200', '3005'],
dtype='|S4')
The obscure documentation, it should be noted that this is roughly 4 times slower then choosing dtype="S.."
, but non-linearly faster then using np.array(map(str,a))
methods.
You can also do some neat things:
>>> a
[1234.5, 123.4, 12345]
>>> np.char.mod('%s',a)
array(['1234.5', '123.4', '12345.0'],
dtype='|S7')
>>> np.char.mod('%f',a)
array(['1234.500000', '123.400000', '12345.000000'],
dtype='|S12')
>>> np.char.mod('%d',a) #Note the truncation of decimals here.
array(['1234', '123', '12345'],
dtype='|S5')
>>> np.char.mod('%s.stuff',a)
array(['1234.5.stuff', '123.4.stuff', '12345.0.stuff'],
dtype='|S13')
Additional information can be found here.
dtype='|S3'
and see if that gives what you expect?numpy
tag should lead you to it.'|S3'
worksnp.array([101,201,301],dtype=str)
instead?