概述:
numpy.isNaN(array[,out] ) :测试每个元素是否为nan,并以布尔数组形式返回结果。
array : [ array _ like ] inputarrayorobjectwhoseelements,we need to test for infinity
out :[ndarray,optional ] outputarrayplacedwithresult。
itstypeispreservedanditmustbeoftherightshapetoholdtheoutput。
返回:
booleanarraycontainingtheresult.forscalarinput,theresultisanewbooleanwithvalue
trueiftheinputispositiveornegativeinfinity; otherwise the value is False。
For array input,theresultisabooleanarraywiththesameshapeastheinputandthevalues
aretruewherethecorrespondingelementoftheinputispositiveornegativeinfinity;
elsewhere the values are False。
# python程序设计
# numpy.isnan () method
导入编号为geek
print(ISnan: )、geek.Isnan(1)、(n ) )
print(ISnan: )、geek.Isnan(0)、(n ) )
# not a number
print(ISNan: )、geek.Isnan )和“n”
# infinity
print(ISnan: )、geek.isnan (geek.INF )、(n ) ) ) ) ) ) ) ) ) ) 652
print(ISnan: )、geek.isnan (geek.ninf )和“n”
x=geek.Array([-geek.INF,0 .geek.inf] ) )。
y=geek.array ([ 2,2,2 ] ) )。
print('checkingforNan: ',geek.isnan(x () x,y ) ) ) ) ) ) ) ) ) )。
输出:
is nan :假
is nan :假
Is NaN: True
is nan :假
is nan :假
Checking for NaN: [0 0 0]
# python程序设计
# numpy.isnan () method
导入编号为geek
# returns true/falsevalueforeachelement
b=geek.arange(20 ).reshape (5,4 ) ) ) ) ) ) ) )。
print((n ),b ) ) ) ) ) ) ) ) ) ) ) ) ) ) )。
print((NISNan ) notanumber ) :(n ),geek.isnan(b ) ) ) ) ) ) ) ) 65
b=[[1j],
print((NISNan ) notanumber ) :(n ),geek.isnan(b ) ) ) ) ) ) ) ) 65
输出:
ISnan(notanumber ) :
ISnan(notanumber ) :