numpy(2)

import numpy as np
np.meshgrid(a,b)
a,b:1-D array
return coordinate system of vector a,b
np.where()
arr=np.arange(5)
arr1=np.ones(5)
con=arr>3
result=[(x if c else y)for x,c,y in zip(arr,con,arr1)]
result
Out[142]: [1.0, 1.0, 1.0, 1.0, 4]
np.where(con,arr,arr1)
Out[144]: array([ 1.,  1.,  1.,  1.,  4.])
***con: bool array,
np.cumsum(axis=None):accumulative total sum along axis
np.cumprod(axis=None):accumulative total product along axis
np.std(axis=None): standard deviation(标准差)
np.var(axis=None): variance(方差)
np.any(),np.all(),return bool array or bool
np.unique(arr)
np.in1d(arr1,arr2):element of arr1 in arr2 or not
np.intersect1d(arr,arr1): elements in arr1 and arr meanwhile
np.union(arr,arr1):the union of arr and arr1
np.setdiff1d(arr,arr1):difference set ,elemen in arr not arr1
np.setxor1d(arr,arr1): union - intersection
***save open***
np.save('filename',arr):save arr to a file by the original uncompressed binary, '.npy' as filename extension
np.load('filename.npy'):open npfile
np.savez('filename',arrs)save several arr,'npz' as the filename extension 
np.loadtxt('array_ex.txt',delimiter=',')
np.savetxt('filename',arr)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值