1 逻辑判断:
1.1 &:
vector = numpy.array([5,10,15,20])
equal_to_ten_and_five = (vector==10) & (vector==5)
print(equal_to_ten_and_five)
结果:
[False False False False]
1.2 |:
vector = numpy.array([5,10,15,20])
equal_to_ten_or_five = (vector==10) | (vector==5)
print(equal_to_ten_or_five)
结果:
[ True True False False]
2 整体类型改变:
vector = numpy.array(["1","2","3"])
print(vector.dtype)
vector = vector.astype(float)
print(vector.dtype)
print(vector)
结果:
<U1
float64
[1. 2. 3.]
3 求极值:
vector = numpy.array([5,10,15,20])
vector.min()
结果:
5
4 行列求和
4.1: