3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Python】np.arrayの中のNaNを削除する【備忘】

Last updated at Posted at 2018-10-29

自分用です。

間違ってたらごめんなさい。

こまったこと

np.arrayの中にNaNがあってとても嫌だった。

やってしまったこと

for文で一々NaNなのか判定してしまった。

こうするとよさそう

import numpy as np

arr = np.array([0, 1, 2, np.nan, 3])
print(arr[~np.isnan(arr)])
# array([0., 1., 2., 3.])

すごい

ずっと見ていられる

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?