I'd use logical indexing for this:

a[isnan(a)] = 42
clean_a = a[!isnan(a)]


On Thursday, April 7, 2016 at 9:20:05 AM UTC-4, Kristoffer Carlsson wrote:
>
> to replace with 42, maybe:
>
> map!((i) -> isnan(i)? 42 : i, a)
>
> to delete:
>
> deleteat!(a, find(isnan, a))
>
>
>
>
> On Thursday, April 7, 2016 at 2:33:56 PM UTC+2, jw3126 wrote:
>>
>> I have an array, which has some NaNs and I want to do things like replace 
>> them by 42 or delete them. What is the canonical way to do this?
>>
>

Reply via email to