[Numpy-discussion] Transforming an array of numbers to an array of formatted strings
Thu Mar 13 14:30:09 CDT 2008
On Thu, Mar 13, 2008 at 9:49 AM, Alan G Isaac <email@example.com> wrote:
> And for 1d array ``x`` you can always do::
> strdata = list( fmt%xi for xi in x)
> Nice because the counter name does not "bleed" into your program.
On Thu, Mar 13, 2008 at 3:07 PM, David Huard <firstname.lastname@example.org> wrote:
> ['S%03d'%i for i in int_data]
Thanks for the suggestions! I wasn't sure if there was a magic numpy
method to do the loop quickly (as the destination array is created
beforehand) without creating a temporary Python list, but I guess not.
The generator/list-comprehension is likely better than my prototype.
More information about the Numpy-discussion