[Numpy-discussion] Trim a numpy array in numpy.
Tue Aug 16 16:19:07 CDT 2011
*I have a question regarding how to trim a string array in numpy. *
*>>> import numpy as np*
*>>> x = np.array(['aaa.hdf', 'bbb.hdf', 'ccc.hdf', 'ddd.hdf'])*
*I expect to trim a certain part of each element in the array, for example
'.hdf', giving me ['aaa', 'bbb', 'ccc', 'ddd']. Of course, I can do a loop
thing. However, in my actual dataset, I have more than one million elements
in such an array. So I am wondering is there a faster and better way to do
it, like STRMID function in IDL? I try to google it, but it turns out that
I can not find any discussion about it. Thanks. *
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion