当前位置:网站首页>数据分析04
数据分析04
2022-08-01 22:16:00 【88岁带伤编程】
一、数组的拼接
vstack和hstack方法
数组的行列交换
行交换和列交换
案例:
代码:
其中 axis=0是列,axis=1是行
numpy生成随机数
import numpy as np
ad=np.random.randint(10,20,(3,4)) #取不到20
ac=np.random.uniform(3,10,(3,4))
ae=np.random.normal(10,13,(3,4))
t=np.random.seed(10) #使用了随机种子,所以每一次的随机数都一样
af=np.random.randint(10,20,(3,4))
print(ad)
print("*"*50)
print(ac)
print("*"*50)
print(ae)
print("*"*50)
print(af)
* numpy的注意点:
二、numpy中的nan和inf
numpy中的clip(裁剪):
1.两个nan不相等
2.np.nan!=np,nan
numpy常用的统计函数
对nan进行合理的数字替换
t1=np.arange(12).reshape(3,4).astype("float")
t1[1,2:]=np.nan
print(t1)
def afs(t1):
for i in range(t1.shape[1]):
temp_col=t1[:,i]
nan_num=np.count_nonzero(temp_col!=temp_col)
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
print("*"*50)
t1=afs(t1)
print(t1)
边栏推荐
- AQS
- 小程序容器+自定义插件,可实现混合App快速开发
- Recycling rental system 100% open source without encryption Mall + recycling + rental
- Use Jenkins for continuous integration, this knowledge point must be mastered
- 不卷了!入职字节跳动一周就果断跑了。
- 小程序毕设作品之微信体育馆预约小程序毕业设计成品(4)开题报告
- 恒星的正方形问题
- Deep Learning Course2 Week 2 Optimization Algorithms Exercises
- 小程序毕设作品之微信美食菜谱小程序毕业设计成品(5)任务书
- 图论——强连通分量缩点+拓扑排序
猜你喜欢
力扣第 304 场周赛复盘
SOM Network 1: Principles Explained
小程序毕设作品之微信美食菜谱小程序毕业设计成品(7)中期检查报告
ImportError: `save_weights` requires h5py. Problem solved
kubernetes CoreDNS全解析
How to prevent governance attacks in DAOs?
LeetCode952三部曲之一:解题思路和初级解法(137ms,超39%)
Deep Learning Course2 Week 2 Optimization Algorithms Exercises
KMP 字符串匹配问题
xctf attack and defense world web master advanced area webshell
随机推荐
Ten years after graduation, financial freedom: those things that are more important than hard work, no one will ever teach you
Go 微服务开发框架DMicro的设计思路
Prufer序列
解决 win10 下 ISE14.7的 iMPACT 崩溃问题 - FPGA 笔记
(翻译)按钮的对比色引导用户操作的方式
number of solutions to solve a multivariate multi-degree equation
【ASM】字节码操作 MethodWriter
小程序中的多表联合查询
SOM Network 2: Implementation of the Code
PAM 回文自动机
2022年最新河北建筑八大员(机械员)模拟考试题库及答案
【C语言实现】整数排序-四种方法,你都会了吗、
小程序容器+自定义插件,可实现混合App快速开发
9. SAP ABAP OData 服务如何支持删除(Delete)操作
移动端人脸风格化技术的应用
PAM Palindromic Automata
Flutter基础学习(一)Dart语言入门
46.全排列
(Translation) How the contrasting color of the button guides the user's actions
一种灵活的智能合约协作方式