Created
October 13, 2011 20:26
-
-
Save uchida/1285408 to your computer and use it in GitHub Desktop.
Tokyo.Scipy#2 ディスカッション事前アンケート3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf8 -*- | |
# Tokyo.Scipy#2 ディスカッション事前アンケート | |
# http://www.surveymonkey.com/s/XJ2KNBW | |
# | |
# 3. nanやInfを含む値の列 | |
# x = numpy.array([[1,0,nan,1,Inf,1,....]]) | |
# が与えられたとき、 | |
# NaNやInf以外のxの要素の合計を計算する方法が直ぐに思い浮かびますか? | |
from numpy import array | |
from numpy import nan, Inf, isfinite | |
x = array([[1, 0, nan, 1, Inf, 1]]) | |
res = sum(x[isfinite(x)]) | |
print res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment