当前位置:网站首页>Numpy array creation
Numpy array creation
2022-06-29 22:06:00 【starmultiple】
List of articles
numpy Array creation
import numpy as np
list =[1,2,3,4]
oneArray=np.array(list)
print(list)
print(oneArray)
head
import numpy as np
import random
Simple arrays and their types
t1=np.array([1,2,3])
print(t1)#[1 2 3]
print(type(t1))#<class 'numpy.ndarray'> An array type
t2=np.array(range(10))
print(t2)#[0 1 2 3 4 5 6 7 8 9]
print(type(t2))#<class 'numpy.ndarray'>
Quick array
t3=np.arange(2,10,2)
print(t3)#[2 4 6 8]
print(type(t3))#<class 'numpy.ndarray'>
print(t3.dtype)#int32
numpy Data type of
t4=np.array(range(1,4),dtype="i2")#2 Bytes 16 position
print(t4)#[1 2 3]
print(t4.dtype)#int16
numpy Medium bool type
t5=np.array([1,1,0,1,0,1,0],dtype=bool)
print(t5)#[ True True False True False True False]
print(t5.dtype)#bool
Adjust the data type
t6=t5.astype("int8")
print(t6)#[1 1 0 1 0 1 0]
print(t6.dtype)#int8
numpy The decimal in
t7=np.array([random.random() for i in range(10)])# Default random.random() by 0~1 decimal
print(t7)#[0.32123244 0.74099132 0.89527163 0.82204031 0.65102081 0.38178552 0.50962158 0.34564249 0.63039987 0.39896338]
print(t7.dtype)#float64
Take two decimal places
t8=np.round(t7,3)# Take three decimal places
print(t8)#[0.496 0.981 0.203 0.725 0.056 0.179 0.548 0.934 0.875 0.813]
边栏推荐
- Win10添加ssh公钥
- Alibaba product details API interface (item_get- get product details interface), Alibaba API interface
- How to integrate MES system with ERP? This article tells you the answer
- CLI tool foundation of ros2 robot f1tenth
- [force deduction 10 days SQL introduction] day7+8 calculation function
- Go standard library context package: data, cancellation signal, deadline and other related operations between a single request and multiple goroutines and the request domain
- 89. (cesium article) cesium aggregation diagram (custom picture)
- Matlab adds noise / disturbance to data
- Taro2.* applet configuration sharing wechat circle of friends
- Vipshop product details API interface (item_get- get vipshop product details interface), vipshop details API interface
猜你喜欢

ASP.NET 跨页面提交(Button控件页面重定向)

DevCloud加持下的青软,让教育“智”上云端

为什么要同时重写hashcode和equals方法之简单理解

小型圖書館項目總結

Autodesk Revit 2023 software installation package download and installation tutorial

Mysql入库不了表情符号怎么办

Sophon CE community edition goes online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool

华为云AOM 2.0版本发布
![The inadvertently discovered [tidb cache table] can solve the read / write hotspot problem](/img/96/b1595b9d2b008b353765caa68fdd3c.png)
The inadvertently discovered [tidb cache table] can solve the read / write hotspot problem

89. (cesium article) cesium aggregation diagram (custom picture)
随机推荐
DevCloud加持下的青软,让教育“智”上云端
Common PostgreSQL data operation notes: time
Deep learning remote sensing data set
Report delivery engineer
C. Most Similar Words
[advanced ROS chapter] lesson 2 custom header and source file encapsulation
Amazon Product details API interface - (item_get get Amazon Product details interface), Amazon details API interface
A mysql IBD file is too large processing record
What is unique about MES system?
Cout ambiguous problem
Star ring technology data security management platform defender heavy release
Use of golang gopsutil Library: process and system resource monitoring (CPU, memory, disk, etc.)
DevCloud加持下的青软,让教育“智”上云端
什么是 SYN 洪水攻击?如何防护?
Autodesk Revit 2023 software installation package download and installation tutorial
API interfaces for all products in Alibaba stores (item_search_shop- obtain all product interfaces in the store), Alibaba API interfaces
报表交付工程师
Numpy's research imitation 1
Don't worry about form deformation anymore