Tang机器学习课程笔记之六(Numpy库)

本文探讨了Python中列表(list)与NumPy数组的主要区别。列表可以存储不同格式的数据,而NumPy数组要求所有元素为同一格式。此外,还对比了列表与元组(tuple)的特性,以及如何操作NumPy数组的切片。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

the difference of list and numpy :

list : it can store any format value at the same time, such as int, str
numpy:the inside of the numpy.array must be the same format

the difference of list and tuple :
list: it is an ordered set.it can add and delete any element of the set by any time.
tuple: it is also an ordered set.But it can not add and delete any element of the set when it is initialized.

the operation of slice:
vector=numpy.array([5,10,15,20])
print(vector[0:3])#[0:3]代表一个左开右闭的区间
[5,10,15]

B[:3]表示:索引从0开始取,直到索引3为止,但不包括索引3。即索引0、1、2,正好3个元素。
B[:]原样复制一个list
B[:10:2]前10个数,每两个取一个
B[::2]所有数,每两个取一个

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值