numpy.array的作用

  1. np.array函数的作用:列表不存在维度问题,但数组是有维度的,而np.array()的作用就是把列表转化为数组,也可以说是用来产生数组。

  2. numpy document中对list和numpy array区别的解释:
    【3.5 What’s the difference between a Python list and a NumPy array?】
    NumPy gives you an enormous range of fast and efficient ways of creating arrays and manipulating numerical data inside them. While a Python list can contain different data types within a single list, all of the elements in a NumPy array should be homogeneous. The mathematical operations that are meant to be performed on arrays would be extremely inefficient if the arrays weren’t homogeneous.
    Why use NumPy?
    NumPy arrays are faster and more compact than Python lists. An array consumes less memory and is convenient to use. NumPy uses much less memory to store data and it provides a mechanism of specifying the data types. This allows the code to be optimized even further.
    总结起来就是:
    (1)numpy array[数组]中的元素要是同类型的;
    (2)numpy array更快更紧凑,占用的空间更小,而且它提供了一种指定数据类型的机制。

  3. numpy.array 常用变量及参数:
    dtype变量:用来存放数据类型, 创建数组时可以同时指定。
    object:必选参数,类型为array_like。
    copy:可选参数,类型为bool值。如果为true(默认值),则复制对象。
    shape变量:存放数组的大小, 这人值是可变的, 只要确保无素个数不变的情况下可以任意修改。(-1为自动适配, 保证个数不变)

常用函数的作用

  • 0
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值