“”"
@theme numpy
@time 2018/12/14
@author lz
@content no.unique去重
“”"
import numpy as np
arr1=np.array([“java”,“java”,“C语言”,“C++”,“C#”,“Pyhton”])
print("-"*10,“原始数据”,"-"*10)
for i in arr1:
print(i)
print(“good”)
arr2=np.unique(arr1)
print("-"*10,“去重的数据”,"-"*10)
for j in arr2:
print(j)
print(“hello”)
运行结果:
“”"
@theme numpy
@time 2018/12/14
@author lz
@content no.where
“”"
import numpy as np
arr1=np.array([7,2,9,5,4])
arr2=np.array([4,6,8,10,12])
condition=arr1>arr2
result1=[x if c else y for (x,y,c) in zip(arr1,arr2,condition)]
result2=np.where(condition,arr1,arr2)
print(“使用pytho
机器学习之python基础库numpy
最新推荐文章于 2024-04-13 20:36:03 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)