Python3 Numpy Quickstart学习笔记整理

注:因为Numpy的官方文档是全英文的,本篇文章也基本使用英文写作,部分知识、注释有中文。

1. Quickstart Tutorial 

1.1  Prerequisites

 

1.2  The Basics

  • ndarray.ndim

The number of the axis(dimensions) of the array

  • ndarray.shape

The dimension of a array. If a matrix with nrows and mcolumns, the shape will be (n,m)

  • ndarray.size

The total number of elements of the array. This is equal to the product of the elements of shape.

  • ndarray.dtype

An object describing the type of the elements in the array.

  • ndarray.itemsize

The size in bytes of each element of the array. For example, an array of elements of type float64 has itemsize 8 (=64/8), while one of type complex32 has itemsize 4 (=32/8).

  • ndarray.data

The buffer containing actual elements of the array.

  • # Example

>>> import numpy as np
>>> a = np.arange(15).reshape(3,5)
>>> a
array([[ 0,  1,  2,  3,  4],

       [ 5,  6,  7,  8,  9],

       [10, 11, 12, 13, 14]])
>>> a.shape
(3, 5)
>>> a.itemsize
8
>>> a.dtype
dtype('int64')
>>> a.dtype.name
'int64'
>>> a.size
15
>>> a.ndim
2
>>> type(a)
<class 'numpy.ndarray'>

 

1.3  Array Creation

1)Create an array from a regular Python list or tuple using the array function

  • Example

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值