编程实践(Numpy)上 Task1:数据类型及数组创建(2天)

  • 熟悉基础常量、常见数据类型,以及时间日期和时间增量的处理。
  • 掌握数组的创建和数组的属性。

常量

numpy.nan

numpy.inf

numpy.pi

numpy.e

数据类型

类型备注说明
bool_ = bool88位布尔类型
int8 = byte8位整型
int16 = short16位整型
int32 = intc32位整型
int_ = int64 = long = int0 = intp64位整型
uint8 = ubyte8位无符号整型
uint16 = ushort16位无符号整型
uint32 = uintc32位无符号整型
uint64 = uintp = uint0 = uint64位无符号整型
float16 = half16位浮点型
float32 = single32位浮点型
float_ = float64 = double64位浮点型
str = unicode = str0 = unicode Unicode 字符串
datetime64 日期时间类型
timedelta64 表示两个时间之间的间隔
字符对应类型备注
bboolean'b1'
isigned integer'i1', 'i2', 'i4', 'i8'
uunsigned integer'u1', 'u2' ,'u4' ,'u8'
ffloating-point'f2', 'f4', 'f8'
ccomplex floating-point 
mtimedelta64表示两个时间之间的间隔
Mdatetime64日期时间类型
Oobject 
S(byte-)stringS3表示长度为3的字符串
UUnicodeUnicode 字符串
Vvoid 

时间日期和时间增量

datetime64 基础

日期单位代码含义时间单位代码含义
Yh小时
Mm分钟
Ws
Dms毫秒
--us微秒
--ns纳秒
--ps皮秒
--fs飞秒
--as阿托秒

数组的创建

数组的创建

numpy 提供的最重要的数据结构是ndarray,它是 python 中list的扩展。

1. 依据现有数据来创建 ndarray

(a)通过array()函数进行创建。

(b)通过asarray()函数进行创建

(c)通过fromfunction()函数进行创建

2. 依据 ones 和 zeros 填充方式

(a)零数组

(b)1数组

(c)空数组

(d)单位数组

(e)对角数组

(f)常数数组

3. 利用数值范围来创建ndarray

4. 结构数组的创建

(a)利用字典来定义结构

(b)利用包含多个元组的列表来定义结构

数组的属性

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值