当前位置:网站首页>Data Analysis 6
Data Analysis 6
2022-08-01 07:27:00 【Toward the sun. 178】
目录
编辑numpyConstructor for special arrays
The generated random number does not change
numpy常用统计函数
#均值
print(np.mean(u4,axis=1))
#中值
print(np.median(u4))
#极值
print(np.ptp(u4))
#标准差
print(np.std(u4))
数组拼接
t1=np.arange(0,12).reshape(2,6)
t2=np.arange(12,24).reshape(2,6)
t3=np.vstack((t1,t2))#水平拼接
t4=np.hstack((t1,t2))#竖直拼接
print(t3)
print(t4)
numpyConstructor for special arrays
2行3列全为0的数组
t5=np.zeros((2,3))
print(t5)
对角线为1
t6=np.eye((3))#3行3列
print(t6)
t6[t6==1]=-1
print(t6)
随机数
print(np.random.randint(10,20,(4,5)))
The generated random number does not change
np.random.seed(1)
print(np.random.randint(0,20,(3,4)))
nan
nan的定义
nan(not a numb):不是一个数字,每个nan是不同的,并且nan属于float类型
判断nan的个数
np.count_nonzero(t!=t)
np.isnan(t)
如何将nan替换成均值
def fill_narray(t1):
for i in range(t1.shape[1]):
temp_col=t1[:,i]
nan_num=np.count_nonzero(temp_col!=temp_col)#统计nan的个数
if nan_num!=0:
temp_not_nan_col=temp_col[temp_col==temp_col]
temp_col[np.isnan(temp_col)]=temp_not_nan_col.mean()
return t1
t1=np.arange(12).reshape(3,4).astype("float")
t1[1,2:]=np.nan
print(t1)
t2=fill_narray(t1)
print(t2)
边栏推荐
- Detailed explanation of the crawler framework Scrapy
- 微信小程序请求封装
- 我的创作纪念日
- Monitor the width and height of the parent element, adapt to the size of the plug-in
- I have three degrees, and I have five faces. I was "confessed" by the interviewer, and I got an offer of 33*15.
- Srping中bean的生命周期
- Vim三种模式
- Dart exception details
- 【ASWC Arxml结构分解】-7-Explicit(显式)和Implicit(隐式) Sender-Receiver communication描述差异
- NIO programming
猜你喜欢
MATLAB program design and application of MATLAB 2.5
案例实践 --- Resnet经典卷积神经网络(Mindspore)
研发过程中的文档管理与工具
【手撕AHB-APB Bridge】~ AHB地址总线的低两位为什么不用来表示地址呢?
【MySQL】操作表DML相关语句
小程序全面屏手势配置案例
信息系统项目管理师必背核心考点(五十六)配置控制委员会(CCB)的工作
「面经分享」西北大学 | 字节 生活服务 | 一面二面三面 HR 面
dbeaver连接MySQL数据库及错误Connection refusedconnect处理
The log causes these pits in the thread block, you have to prevent
随机推荐
POJ1251丛林之路题解
mysql中添加字段的相关问题
数据分析5
【MySQL】操作表DML相关语句
Vim扩展内容
LeetCode240+312+394
pytest接口自动化测试框架 | 单个/多个参数
crypto-js uses
LeetCode240+312+394
datagrip 报错 “The specified database userpassword combination is rejected...”的解决方法
rhcsa 第三次
Image lossless compression software which works: try completely free JPG - C image batch finishing compression reduces weight tools | latest JPG batch dressing tools download
The log causes these pits in the thread block, you have to prevent
Information system project managers must recite the work of the core test site (56) Configuration Control Board (CCB)
centos 安装php7.4,搭建hyperf,转发RDS
问下 mysql向pg同步多个表的话 有什么好的方案吗?
NIO programming
Vim三种模式
案例实践 --- Resnet经典卷积神经网络(Mindspore)
MATLAB程序设计与应用 2.5 MATLAB运算