如何避免多次使用“isnan”来过滤数据集inconsitent? [英] How to avoid the multiple use of 'isnan' to filter inconsitent datasets?

查看:293
本文介绍了如何避免多次使用“isnan”来过滤数据集inconsitent?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个对应的(有一个关系,并且具有相同的尺寸)的数据集

I have two corresponded (has a relation and has the same dimension) dataset:


  1. 时间

  2. 盐度

  1. Time
  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆