[SciPy-User] [scipy-user] How to remove a value from an np array?
Mon Jan 30 08:22:01 CST 2012
Sorry to be boring but do you have any idea?
I want to have an array with 2 columns and erase the entire line when
it find a "nan" in the second column?
2012/1/27 Fabien Lafont <firstname.lastname@example.org>:
> 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 <email@example.com>:
>> 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) 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.
>> SciPy-User mailing list
More information about the SciPy-User