当前位置:网站首页>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]
边栏推荐
- Huawei cloud AOM version 2.0 release
- This time, I will talk about technology and life
- 硅树脂油漆申请美国标准UL 790 Class A 合适吗?
- Huawei cloud AOM version 2.0 release
- Bs-gx-017 online examination management system based on SSM
- 为什么要同时重写hashcode和equals方法之简单理解
- Small library project summary
- cout 不明确问题
- Mysql入库不了表情符号怎么办
- Structure the fifth operation of the actual camp module
猜你喜欢

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

报表交付工程师

Win10添加ssh公钥

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

Deep learning remote sensing data set

Small library project summary

The logic behind the three whys encountered in technical communication

Star ring technology data security management platform defender heavy release

MySQL backup and restore

细说GaussDB(DWS)复杂多样的资源负载管理手段
随机推荐
Win10 add SSH public key
cout 不明确问题
Data mining review
Simple analysis of wieshark packet capturing MySQL protocol
唯品会商品详情API接口(item_get-获得唯品会商品详情接口),唯品会详情API接口
How to use filters in jfinal to monitor Druid for SQL execution?
jfinal中如何使用过滤器监控Druid监听SQL执行?
Matlab adds noise / disturbance to data
A mysql IBD file is too large processing record
Top ten questions for senior Performance Test Engineer
22 years of a doctor in Huawei
Water polo chart - using dynamic ripples to show percentages
Layer 3 loop brought by route Summary - solution experiment
How to integrate MES system with ERP? This article tells you the answer
R language plot visualization: plot visualization box graph and several box plots of multiple classification variables
亚马逊商品详情API接口-(item_get-获得AMAZON商品详情接口),亚马逊详情API接口
Does rapid software delivery really need to be at the cost of security?
细说GaussDB(DWS)复杂多样的资源负载管理手段
Aleph farms hired a supervisor of regulatory affairs to prepare for global commercialization in advance
Alibaba keyword search commodity API interface (item_search- commodity search interface by keyword), Alibaba Search API interface