[Numpy-discussion] Non-numeric arrays?
Magnus Lie Hetland
magnus at hetland.org
Thu Apr 25 07:54:02 EDT 2002
Magnus Lie Hetland <magnus at hetland.org>:
[snip]
Just a quick explanation for why I'm interested in this...
I've got a two-dimensional array of ints (or bytes, actually), that I
would like to convert to a delimited string (e.g. comma-separated).
This works in Numeric:
>>> from string import letters
>>> alphabet = array(letters)
>>> data = arange(24) # E.g...
>>> data.shape = 6, 4
>>> fields = sum(take(alphabet, data), 1)
>>> ','.join(fields)
'abcd,efgh,ijkl,mnop,qrst,uvwx'
--
Magnus Lie Hetland The Anygui Project
http://hetland.org http://anygui.org
More information about the NumPy-Discussion
mailing list