Numpy

这里写自定义目录标题

Numpy

import numpy as np
a = np.array([[1,2,3],[2,3,4]])
print(f'a.ndim={a.ndim}')
print(f'a.shape={a.shape}')
print(f'a.size={a.size}')
print(f'a.dtype={a.dtype}')
print(f'a.itemsize={a.itemsize}')  # the size in bytes of each element of the array. 
print(f'a.data={a.data}') # the buffer containing the actual elements of the array.
np.zeros((3, 4))
np.ones((3, 4),dtype = np.int16) # default type is float64
np.arange(0, 2, 0.3)
from numpy import pi
x = np.linspace(0, 2 * pi, 100)        # useful to evaluate function at lots of points
f = np.sin(x)  # 9 numbers from 0 to 2
c = np.arange(24).reshape(2, 3, 4)

Basic Operations
b**2
10 * np.sin(a)
a < 35
a.sum()
a.min()
a.max()
b.sum(axis=0)     # sum of each column
b.min(axis=1)     # min of each row
b.cumsum(axis=1)  # cumulative sum along each row

A = np.array([[1, 1],
              [0, 1]])
B = np.array([[2, 0],
              [3, 4]])
A * B     # elementwise product
A @ B     # matrix product
A.dot(B)  # matrix product
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值