[SciPy-User] [scipy-user] How to remove a value from an np array?

Fabien Lafont lafont.fabien@gmail....
Fri Jan 27 12:28:38 CST 2012


I have another. First I expose my problem I have datas like that. Is
it possible to create an array with two columns and then do something
to erase the entire line(both time and points) where nan appears?

X(Time)     Points
1                  5
2                 nan
3                  3
4                  4
5                 nan

2012/1/27 David Warde-Farley <wardefar@iro.umontreal.ca>:
> On Fri, Jan 27, 2012 at 06:48:45PM +0100, Fabien Lafont wrote:
>> And how can I remove a specific element designated by its position
>> numer? like remove(a[8]) for exemple.
> This is generally not something you want to be doing with NumPy arrays. NumPy
> arrays represent fixed blocks of memory, removing an element means
> reallocating the array and copying values before and after position 8 is the
> only way.
> If a is one-dimensional, then np.concatenate(a[:8], a[9:]) will do the job,
> but if you are going to be frequently performing this kind of operation you
> will get better performance out of a plain Python list.
> David
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user

More information about the SciPy-User mailing list