版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_27912569/article/details/84316283
#笔记1:利用python进行数据分析
numpy模块,各种函数等等
因为不想使用编码软件,所以直接文本编辑器,cmd运行结果;
提一个小技巧:cmd中复制信息操作,右击–》标记–》选择需要复制的信息(一般为白色背景)–》在复制区外右击,之后在需要的地方-》ctrl+v 就可以了;
直接上码:
import numpy as np
import matplotlib.pyplot as plt
print('list转换成numpy数组--array')
data1 = [6, 7.5, 8, 0, 1]
arr1 = np.array(data1)
print('array:',arr1)
print('np:ndim--数组维数的维,shape--数组维数统计')
print('以下一一验证')
data2=[[1,2,3,4,5],[6,7,8,9,10]]
data22=[[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15]]
arr2=np.array(data2)
print(arr2)
print('ndim:',arr2.ndim)
print('shape:',arr2.shape)
arr22=np.array(data22)
print(arr22)
print('ndim:',arr22.ndim)
print('shape:',arr22.shape)
data23=[[[1,2,3,4,5],[1,2,3,4,5]],[[6,7,8,9,10],[6,7,8,9,10]],[[11,12,13,14,15],[11,12,13,14,15]]]
arr23=np.array(data23)
print(arr23)
print('ndim:',arr23.ndim)
print('shape:',arr23.shape)
print('判定numpy的数组类型--dtype,也可以用于数据类型转换')
print(arr1.dtype)
print(arr2.dtype)
print('arr.astype(np.float32)')
print('numpy数组函数:zeros--生成数值为0的数组,ones--为1,empyt--未初始化的拦击值,——like--数组复制')
arr3=np.zeros(10)
arr4=np.ones(10)
arr5=np.zeros((3,6))
arr6=np.ones((2,5))
arr7=np.empty(10)
arr8=np.empty((2,3,4))
arr10=np.ones_like(arr8)
print('np.ones(10)',arr3)
print('np.ones(10)',arr4)
print('np.zeros((3,6))\n',arr5)
print('np.ones((2,5))\n',arr6)
print('np.empty(10)\n',arr7)
print('np.empty((2,3,4))\n',arr8)
print('np.ones_like(arr8)\n',arr10)
print('numpy--范围数组')
arr9=np.arange(15)
print('np.arange(15)',arr9)
print('eye--矩阵数组,对角线数字为1,其他数据为零')
arr11=np.eye(3,3)
print('np.eye(3,3)\n',arr11)
print('identity--矩阵数组,对角线数字为1,其他数据为零')
arr12=np.identity(5)
print('np.identity(5)\n',arr12)
print('list排序,sort是内建函数,其中参数reverse控制升降的序列')
testlist=[9,5,4,8,7,6,3,11,55,99,66,88,44,33,12]
print(testlist)
testlist.sort()
print(testlist)
testlist.sort(reverse=True)
print(testlist)
#print(testlist.sort().reverse())
print('**********数组及标量之间的运算***************')
print('数组切片')
arr_slice=np.array([1,2,3,4,5,6,5])
print('切片:arr_slice[2:5]\n',arr_slice[2:5])
print(arr_slice)
print('arr_slice[:] \n',arr_slice[:])
cc=20
print('获取切片的副本而非视图时,需要显示复制copy')
cp=arr_slice[2].copy()
print(cp)
print('数组运行,就是对整个数据元素级别的运算')
print('arr_slice:\n',arr_slice)
print('arr_slice+2:\n',arr_slice+2)
print('数组判断,直接获取boolon值,arr_slice==5:\n',arr_slice==5)
data=np.random.randn(7,4)
print(data)
print(data[arr_slice==5])
print(data[[4,6]])
print('numpy --sqrt 平方根函数')
arrsqrt=np.arange(10)
print('arrsqrt\n',arrsqrt)
print('np.sqrt(arrsqrt)\n',np.sqrt(arrsqrt))
print('np.exp(arrsqrt)\n',np.exp(arrsqrt))
print('元素级最大值--maximum')
x=np.random.randn(8)
y=np.random.randn(8)
print('x 和 y 的值:',x,'\n',y)
print('np.maximum(x,y):\n',np.maximum(x,y))
print('nodf--将数组的小数和整数部分一2个独立数据形式返回')
arrmodf=np.random.randn(7)*5
print('arrmodf:\n',arrmodf)
print('np.modf(arrmodf):\n',np.modf(arrmodf))
结果展示:
list转换成numpy数组--array
array: [6. 7.5 8. 0. 1. ]
np:ndim--数组维数的维,shape--数组维数统计
以下一一验证
[[ 1 2 3 4 5]
[ 6 7 8 9 10]]
ndim: 2
shape: (2, 5)
[[ 1 2 3 4 5]
[ 6 7 8 9 10]
[11 12 13 14 15]]
ndim: 2
shape: (3, 5)
[[[ 1 2 3 4 5]
[ 1 2 3 4 5]]
[[ 6 7 8 9 10]
[ 6 7 8 9 10]]
[[11 12 13 14 15]
[11 12 13 14 15]]]
ndim: 3
shape: (3, 2, 5)
判定numpy的数组类型--dtype,也可以用于数据类型转换
float64
int32
arr.astype(np.float32)
numpy数组函数:zeros--生成数值为0的数组,ones--为1,empyt--未初始化的拦击值,—
—like--数组复制
np.ones(10) [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
np.ones(10) [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
np.zeros((3,6))
[[0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0.]]
np.ones((2,5))
[[1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1.]]
np.empty(10)
[2.71336269e+209 8.18497806e-119 3.53364474e+246 8.49357523e-119
6.38796479e+029 5.98129881e-154 1.58456326e+029 1.00887452e-109
9.63197468e-196 8.54094678e+197]
np.empty((2,3,4))
[[[2.22523004e-307 1.24610994e-306 9.34605037e-307 1.37960283e-306]
[3.56043054e-307 1.37961641e-306 2.22518251e-306 1.33511969e-306]
[1.05694828e-307 1.11261027e-306 1.11261502e-306 1.42410839e-306]]
[[7.56597770e-307 6.23059726e-307 1.42420481e-306 1.24612013e-306]
[6.89804132e-307 8.34447260e-308 1.16820707e-307 1.33511562e-306]
[1.42410974e-306 1.00132228e-307 1.33511969e-306 2.18568966e-312]]]
np.ones_like(arr8)
[[[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]]
[[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]]]
numpy--范围数组
np.arange(15) [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]
eye--矩阵数组,对角线数字为1,其他数据为零
np.eye(3,3)
[[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]]
identity--矩阵数组,对角线数字为1,其他数据为零
np.identity(5)
[[1. 0. 0. 0. 0.]
[0. 1. 0. 0. 0.]
[0. 0. 1. 0. 0.]
[0. 0. 0. 1. 0.]
[0. 0. 0. 0. 1.]]
list排序,sort是内建函数,其中参数reverse控制升降的序列
[9, 5, 4, 8, 7, 6, 3, 11, 55, 99, 66, 88, 44, 33, 12]
[3, 4, 5, 6, 7, 8, 9, 11, 12, 33, 44, 55, 66, 88, 99]
[99, 88, 66, 55, 44, 33, 12, 11, 9, 8, 7, 6, 5, 4, 3]
**********数组及标量之间的运算***************
数组切片
切片:arr_slice[2:5]
[3 4 5]
[1 2 3 4 5 6 5]
arr_slice[:]
[1 2 3 4 5 6 5]
获取切片的副本而非视图时,需要显示复制copy
3
数组运行,就是对整个数据元素级别的运算
arr_slice:
[1 2 3 4 5 6 5]
arr_slice+2:
[3 4 5 6 7 8 7]
数组判断,直接获取boolon值,arr_slice==5:
[False False False False True False True]
[[ 1.47253514 -2.44902682 1.13812205 0.14589991]
[ 0.68373373 -0.23366184 -0.27223464 1.71469428]
[-0.07041122 0.62303681 0.95898338 -0.81384621]
[-1.06898661 0.627502 -0.23341503 0.65571662]
[ 0.58839865 -0.75535174 -0.35730241 -0.34919981]
[ 1.68777775 -0.30818458 2.04453755 -1.57759168]
[ 0.71897125 1.73441183 0.65232242 -0.06775045]]
[[ 0.58839865 -0.75535174 -0.35730241 -0.34919981]
[ 0.71897125 1.73441183 0.65232242 -0.06775045]]
[[ 0.58839865 -0.75535174 -0.35730241 -0.34919981]
[ 0.71897125 1.73441183 0.65232242 -0.06775045]]
numpy --sqrt 平方根函数
arrsqrt
[0 1 2 3 4 5 6 7 8 9]
np.sqrt(arrsqrt)
[0. 1. 1.41421356 1.73205081 2. 2.23606798
2.44948974 2.64575131 2.82842712 3. ]
np.exp(arrsqrt)
[1.00000000e+00 2.71828183e+00 7.38905610e+00 2.00855369e+01
5.45981500e+01 1.48413159e+02 4.03428793e+02 1.09663316e+03
2.98095799e+03 8.10308393e+03]
元素级最大值--maximum
x 和 y 的值: [ 0.17431847 0.28680556 1.85782297 1.03780585 -1.22376584 0.48
353147
0.95340868 -0.61662407]
[-0.65832693 0.53254895 -0.76633331 -0.46840485 -0.99966711 0.53170305
0.46197655 -1.07052881]
np.maximum(x,y):
[ 0.17431847 0.53254895 1.85782297 1.03780585 -0.99966711 0.53170305
0.95340868 -0.61662407]
nodf--将数组的小数和整数部分一2个独立数据形式返回
arrmodf:
[ 3.69746112 -0.19319961 -3.28349768 -0.17373054 0.37827685 4.32382365
-0.26977041]
np.modf(arrmodf):
(array([ 0.69746112, -0.19319961, -0.28349768, -0.17373054, 0.37827685,
0.32382365, -0.26977041]), array([ 3., -0., -3., -0., 0., 4., -0.]))
数组运算部分:
print('****************利用数组进行数据处理****************************')
points=np.arange(-5,5,0.01)
xs,ys=np.meshgrid(points,points)
print(xs,'\n',ys)
z=np.sqrt(xs ** 2+ys ** 2)
print(z)
#plt.imshow(z,cmap=plt.cm.gray)
plt.imshow(z)
plt.colorbar()
plt.title("Image plot of $\sqrt{x^2+y^2}$ for a grid of values")
#plt.show()
print('********将条件逻辑表述为数组运算**************')
print('where是函数三元表达式的矢量化版本 x if condition else y')
xarr=np.random.randn(5)+1
yarr=np.random.randn(5)+2
cond=yarr<2
print('三组数据 xarr,yarr,cond:\n',xarr,'\n',yarr,'\n',cond)
print('np.where(cond,yarr,xarr):\n',np.where(cond,yarr,xarr))
print('也可用于数据替换')
arrn=np.random.randn(4,4)
print('arrn:\n',arrn)
print('np.where(arrn>0,2,-2):\n',np.where(arrn>0,2,-2))
print('最猛的where表达式:np.where(x & y,0,np.where(x,1,np.where(y,2,3)))')
print('**************数学和统计方法***************************')
arrstatistics=np.random.randn(4,5)
print('np.random.randn(5,4):\n',np.random.randn(5,4))
print('平均数mean():\n',arrstatistics.mean())
print('和sum():\n',arrstatistics.sum())
print('axis参数,定义统计位置,统计的维度')
print('平均数mean(axis=1):\n',arrstatistics.mean(axis=1))
print('和sum(axis=0):\n',arrstatistics.sum(axis=0))
print('累计求和cumsum和求积cumprod,其中的参数定义是统计的维度')
arrcum=np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
print('原始数据:\n',arrcum)
print('np.shape(arrcum):\n',np.shape(arrcum))
print('cumsum累计求和,arrcum.cumsum(0):\n',arrcum.cumsum(0))
print('cumprod累计求积,arrcum.cumprod(0):\n',arrcum.cumprod(0))
print('cumsum累计求和,arrcum.cumsum(1):\n',arrcum.cumsum(1))
print('cumprod累计求积,arrcum.cumprod(1):\n',arrcum.cumprod(1))
print('******************用于boolean数组的方法*************')
print('在python中有时boolean是可以与0 1相互使用的')
arrbool=np.random.randn(10)
print('(np.random.randn(100)>0).sum():\n',(arrbool>0).sum())
bools=arrbool>0
print('boolean数组:\n',bools)
print('bools.any()判断数组中是否有true:',bools.any())
print('bools.all()判断数组中是否全部是true:',bools.all())
print('\n**************排序*****************\n')
print('sort可以排序,数组可以按照轴向上排序')
arrsort=np.random.randn(8)
print('np.random.randn(8):\n',arrsort)
arrsort.sort()
print('sort()排序,同时sort是内建函数:\n',arrsort)
arrsort2=np.random.randn(3,4)
print('np.random.randn(3,4):\n',arrsort2)
arrsort2.sort(1)
print('数组排序,按照维度,arrsort2.sort(0):\n',arrsort2)
sortnp=np.random.randn(5)
print(np.sort(sortnp))
print('\n**********唯一化以及其他的集合逻辑*******************\n')
print('类似于数组去重且排序')
names=np.array(['bob','joe','will','lily','will','joe'])
print('数组:\n',names)
print('np.unique(names)数组去重且排序:\n',np.unique(names))
结果展示:
****************利用数组进行数据处理****************************
[[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
...
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]]
[[-5. -5. -5. ... -5. -5. -5. ]
[-4.99 -4.99 -4.99 ... -4.99 -4.99 -4.99]
[-4.98 -4.98 -4.98 ... -4.98 -4.98 -4.98]
...
[ 4.97 4.97 4.97 ... 4.97 4.97 4.97]
[ 4.98 4.98 4.98 ... 4.98 4.98 4.98]
[ 4.99 4.99 4.99 ... 4.99 4.99 4.99]]
[[7.07106781 7.06400028 7.05693985 ... 7.04988652 7.05693985 7.06400028]
[7.06400028 7.05692568 7.04985815 ... 7.04279774 7.04985815 7.05692568]
[7.05693985 7.04985815 7.04278354 ... 7.03571603 7.04278354 7.04985815]
...
[7.04988652 7.04279774 7.03571603 ... 7.0286414 7.03571603 7.04279774]
[7.05693985 7.04985815 7.04278354 ... 7.03571603 7.04278354 7.04985815]
[7.06400028 7.05692568 7.04985815 ... 7.04279774 7.04985815 7.05692568]]
********将条件逻辑表述为数组运算**************
where是函数三元表达式的矢量化版本 x if condition else y
三组数据 xarr,yarr,cond:
[ 1.26243408 1.48311738 -0.07536512 2.18532806 1.18377716]
[ 3.61416886 0.7816586 -0.08830427 2.62565609 2.85934403]
[False True True False False]
np.where(cond,yarr,xarr):
[ 1.26243408 0.7816586 -0.08830427 2.18532806 1.18377716]
也可用于数据替换
arrn:
[[ 0.94335461 -0.58049987 2.38113548 0.49852662]
[-0.54994948 -0.31994696 0.27155128 -0.1202289 ]
[-0.25684742 -0.46311334 0.0054203 -0.07023138]
[-1.3216416 0.61327913 -1.04011719 1.41598978]]
np.where(arrn>0,2,-2):
[[ 2 -2 2 2]
[-2 -2 2 -2]
[-2 -2 2 -2]
[-2 2 -2 2]]
最猛的where表达式:np.where(x & y,0,np.where(x,1,np.where(y,2,3)))
**************数学和统计方法***************************
np.random.randn(5,4):
[[ 0.70970748 -0.4591139 -1.15833358 -0.78405139]
[ 0.46591102 0.35339858 -2.06302841 -0.02693571]
[-1.20844434 -0.64084241 0.75429817 0.93858619]
[ 0.23871791 -0.25767499 -0.59621739 -0.44097582]
[-0.51131581 0.58601802 0.03373255 1.36768605]]
平均数mean():
-0.28012726860314613
和sum():
-5.602545372062923
axis参数,定义统计位置,统计的维度
平均数mean(axis=1):
[-0.74247505 -0.16217004 -0.04852818 -0.1673358 ]
和sum(axis=0):
[-1.02138047 -0.23966593 -1.48753698 0.88226155 -3.73622355]
累计求和cumsum和求积cumprod,其中的参数定义是统计的维度
原始数据:
[[ 1 2 3 4]
[ 5 6 7 8]
[ 9 10 11 12]]
np.shape(arrcum):
(3, 4)
cumsum累计求和,arrcum.cumsum(0):
[[ 1 2 3 4]
[ 6 8 10 12]
[15 18 21 24]]
cumprod累计求积,arrcum.cumprod(0):
[[ 1 2 3 4]
[ 5 12 21 32]
[ 45 120 231 384]]
cumsum累计求和,arrcum.cumsum(1):
[[ 1 3 6 10]
[ 5 11 18 26]
[ 9 19 30 42]]
cumprod累计求积,arrcum.cumprod(1):
[[ 1 2 6 24]
[ 5 30 210 1680]
[ 9 90 990 11880]]
******************用于boolean数组的方法*************
在python中有时boolean是可以与0 1相互使用的
(np.random.randn(100)>0).sum():
4
boolean数组:
[ True False False True True False False False False True]
bools.any()判断数组中是否有true: True
bools.all()判断数组中是否全部是true: False
**************排序*****************
sort可以排序,数组可以按照轴向上排序
np.random.randn(8):
[ 0.20910574 0.40382178 1.8342204 1.25804787 -0.93640235 -1.02153225
1.52891234 1.37000349]
sort()排序,同时sort是内建函数:
[-1.02153225 -0.93640235 0.20910574 0.40382178 1.25804787 1.37000349
1.52891234 1.8342204 ]
np.random.randn(3,4):
[[-0.18118097 2.28582324 -0.78561753 1.02404558]
[ 0.40045074 0.72130552 -0.34748332 0.16252639]
[ 0.24651261 1.24463897 -0.30033206 -1.22524984]]
数组排序,按照维度,arrsort2.sort(0):
[[-0.78561753 -0.18118097 1.02404558 2.28582324]
[-0.34748332 0.16252639 0.40045074 0.72130552]
[-1.22524984 -0.30033206 0.24651261 1.24463897]]
[-2.06422161 -1.33899749 -0.72697942 0.04606701 0.65161994]
E:\JAVA\Idea-workspace\python\data_see>python numpy_test01.py
****************利用数组进行数据处理****************************
[[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
...
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]
[-5. -4.99 -4.98 ... 4.97 4.98 4.99]]
[[-5. -5. -5. ... -5. -5. -5. ]
[-4.99 -4.99 -4.99 ... -4.99 -4.99 -4.99]
[-4.98 -4.98 -4.98 ... -4.98 -4.98 -4.98]
...
[ 4.97 4.97 4.97 ... 4.97 4.97 4.97]
[ 4.98 4.98 4.98 ... 4.98 4.98 4.98]
[ 4.99 4.99 4.99 ... 4.99 4.99 4.99]]
[[7.07106781 7.06400028 7.05693985 ... 7.04988652 7.05693985 7.06400028]
[7.06400028 7.05692568 7.04985815 ... 7.04279774 7.04985815 7.05692568]
[7.05693985 7.04985815 7.04278354 ... 7.03571603 7.04278354 7.04985815]
...
[7.04988652 7.04279774 7.03571603 ... 7.0286414 7.03571603 7.04279774]
[7.05693985 7.04985815 7.04278354 ... 7.03571603 7.04278354 7.04985815]
[7.06400028 7.05692568 7.04985815 ... 7.04279774 7.04985815 7.05692568]]
********将条件逻辑表述为数组运算**************
where是函数三元表达式的矢量化版本 x if condition else y
三组数据 xarr,yarr,cond:
[ 0.99007268 -1.11880488 -0.38605399 0.59386976 1.70623461]
[1.61854825 0.6337754 1.93116283 2.87717606 2.85241642]
[ True True True False False]
np.where(cond,yarr,xarr):
[1.61854825 0.6337754 1.93116283 0.59386976 1.70623461]
也可用于数据替换
arrn:
[[-0.20398996 0.11794209 0.0227026 1.71716702]
[-0.79731314 1.26415283 1.44153618 0.04418537]
[-0.38009871 -0.99222962 -1.52615044 0.83931967]
[-1.19255679 0.96093554 -0.48774968 -0.71865748]]
np.where(arrn>0,2,-2):
[[-2 2 2 2]
[-2 2 2 2]
[-2 -2 -2 2]
[-2 2 -2 -2]]
最猛的where表达式:np.where(x & y,0,np.where(x,1,np.where(y,2,3)))
**************数学和统计方法***************************
np.random.randn(5,4):
[[-1.70376598 -0.50234601 1.55523975 -1.10212304]
[-0.45373985 0.00948484 0.28416607 -0.62475218]
[ 0.08600197 -0.20475063 -0.11132531 0.13814797]
[-0.32343823 -2.93497135 -0.08099377 1.50397584]
[ 0.02241948 0.91416485 1.44763277 1.0781573 ]]
平均数mean():
-0.18957174296527549
和sum():
-3.7914348593055096
axis参数,定义统计位置,统计的维度
平均数mean(axis=1):
[-0.36809082 -0.46193983 -0.73314166 0.80488534]
和sum(axis=0):
[-0.81198514 -1.18956475 -0.06381854 1.59453648 -3.32060291]
累计求和cumsum和求积cumprod,其中的参数定义是统计的维度
原始数据:
[[ 1 2 3 4]
[ 5 6 7 8]
[ 9 10 11 12]]
np.shape(arrcum):
(3, 4)
cumsum累计求和,arrcum.cumsum(0):
[[ 1 2 3 4]
[ 6 8 10 12]
[15 18 21 24]]
cumprod累计求积,arrcum.cumprod(0):
[[ 1 2 3 4]
[ 5 12 21 32]
[ 45 120 231 384]]
cumsum累计求和,arrcum.cumsum(1):
[[ 1 3 6 10]
[ 5 11 18 26]
[ 9 19 30 42]]
cumprod累计求积,arrcum.cumprod(1):
[[ 1 2 6 24]
[ 5 30 210 1680]
[ 9 90 990 11880]]
******************用于boolean数组的方法*************
在python中有时boolean是可以与0 1相互使用的
(np.random.randn(100)>0).sum():
2
boolean数组:
[ True True False False False False False False False False]
bools.any()判断数组中是否有true: True
bools.all()判断数组中是否全部是true: False
**************排序*****************
sort可以排序,数组可以按照轴向上排序
np.random.randn(8):
[-0.02345675 0.64359727 0.58457296 -0.8850154 2.44578301 -1.08562018
0.17500176 -0.71670191]
sort()排序,同时sort是内建函数:
[-1.08562018 -0.8850154 -0.71670191 -0.02345675 0.17500176 0.58457296
0.64359727 2.44578301]
np.random.randn(3,4):
[[-1.68676702 -0.36451105 -2.64072687 0.21919304]
[ 1.68514211 1.80208532 2.23261514 -0.21684161]
[ 1.93498362 -0.53826307 0.00436807 1.48078029]]
数组排序,按照维度,arrsort2.sort(0):
[[-2.64072687 -1.68676702 -0.36451105 0.21919304]
[-0.21684161 1.68514211 1.80208532 2.23261514]
[-0.53826307 0.00436807 1.48078029 1.93498362]]
[-0.58380263 -0.25613384 -0.18538389 0.02038693 3.28734033]
**********唯一化以及其他的集合逻辑*******************
类似于数组去重且排序
数组:
['bob' 'joe' 'will' 'lily' 'will' 'joe']
np.unique(names)数组去重且排序:
['bob' 'joe' 'lily' 'will']```