如何避免多次使用“isnan”来过滤数据集inconsitent? [英] How to avoid the multiple use of 'isnan' to filter inconsitent datasets?
问题描述
我有两个对应的(有一个关系,并且具有相同的尺寸)的数据集
I have two corresponded (has a relation and has the same dimension) dataset:
-
时间
-
盐度
Time
Salinity
在盐度数据有些数据是NaN。
Some data in salinity dataset is NaN.
我可以删除NaN值
Salinity_new=Salinity(~isnan(Salinity))
但它不会对应时间
数据了。
我怎样才能删除对应的时间也?
How can I remove the corresponded time in also?
感谢
推荐答案
Diavakar和Patrik的意见是正确的。概括起来,让这个问题的回答,一些进一步的言论。
The comments of Diavakar and patrik are correct. To sum it up and get this question answered, some further remarks.
mask = isfinite(Salinity)
[Time,Salinity] = deal( Time(mask), Salinity(mask) )
ISFINITE
相同〜isnan
- 但有一个计算步骤少,其约50-90%快点。通过引入屏蔽
你避免双重使用 ISFINITE
的。 交易
只是为您节省一些空间。
isfinite
is the same as ~isnan
- but with one computation step less, its about 50-90% faster. By introducing a mask
you're avoiding the double use of isfinite
. deal
just saves you some space.
这篇关于如何避免多次使用“isnan”来过滤数据集inconsitent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!