numpy函数白板
numpy.linspace(start, stop, num=50, endpoint=True, retstep=False)
start 起始位置
stop 终止位置
num 个数
endpoint 终止位置是否计算
是否返回步长
np.linspace(0, 1, 5)
array([ 0. , 0.25, 0.5 , 0.75, 1. ])
numpy.arange([start, ]stop, [step, ]dtype=None)
- start=None,
stop=None,
step=None,
dtype=None)
- >>> np.arange(3)
- array([0, 1, 2])
- >>> np.arange(3.0)
- array([ 0., 1., 2.])
- >>> np.arange(3,7)
- array([3, 4, 5, 6])
- >>> np.arange(3,7,2)
- array([3, 5])
numpy.meshgrid()
需要XY平面的网格数据,这就是meshgrid函数所实现的内容
>>> x=[1,2,3]
>>> y=[10,11,12,13,14]
>>> X,Y=np.meshgrid(x,y)
>>> X
array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3],
[1, 2, 3],
[1, 2, 3]])
>>> Y
array([[10, 10, 10],
[11, 11, 11],
[12, 12, 12],
[13, 13, 13],
[14, 14, 14]])
- 其网格示意如下,其中XY平面中网格的交点就是上面的X和Y数据值。
numpy.c
Translates slice objects to concatenation along the second axis.
>>> np.c_[1,2,2]
array([[1, 2, 2]])
>>> np.c_[np.array([[1,2,3]]), 0, 0, np.array([[4,5,6]])]
array([[1, 2, 3, 0, 0, 4, 5, 6]])
在第2轴上连接数组
numpy.reshape(a, newshape, order='C')
Gives a new shape to an array without changing its data.[不改变数据的情况下改变矩阵的行列]
>>> a = np.arange(6)
>>> a
array([0, 1, 2, 3, 4, 5])
>>> a.reshape((3,2))
array([[0, 1],
[2, 3],
[4, 5]])
>>> np.reshape(np.ravel(a), (2, 3))
array([[0, 1, 2],
[3, 4, 5]])
>>> np.reshape(a, (2, 3), order='F')
array([[0, 2, 4],
[1, 3, 5]])
>>> np.reshape(np.ravel(a, order='F'), (2, 3), order='F')
array([[0, 2, 4],
[1, 3, 5]])
>>> a = np.array([[1,2,3], [4,5,6]])
>>> np.reshape(a, 6)
array([1, 2, 3, 4, 5, 6])
>>> np.reshape(a, 6, order='F')
array([1, 4, 2, 5, 3, 6])
>>> np.reshape(a, (3,-1))
array([[1, 2],
[3, 4],
[5, 6]])
numpy.ravel(a, order='C')
Return a contiguous flattened array.
返回一个连续的扁平数组。
order : {‘C’,’F’, ‘A’, ‘K’}, optional
等价于:reshape(-1, order=order).
>>> x = np.array([[1, 2, 3], [4, 5, 6]])
>>> np.ravel(x)
array([1, 2, 3, 4, 5, 6])
np.hstack
Stack arrays in sequence horizontally (column wise).[水平扩展数组(列方式)]
取一个数组序列,并水平堆叠,形成一个数组。 重建数组除以hsplit。
- a = np.array([[1],[2],[3]])
- b = np.array([[2],[3],[4]])
- c = np.array([[3],[4],[5]])
- np.hstack((a,c,b))
- #------------
- array([[1, 3, 2],
- [2, 4, 3],
- [3, 5, 4]])
>>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.hstack((a,b))
array([1, 2, 3, 2, 3, 4])
numpy.c
将切片对象转换为沿着第二个轴的连接。
>>> np.c_[np.array([1,2,3]), np.array([4,5,6])]
array([[1, 4],
[2, 5],
[3, 6]])
>>> np.c_[np.array([[1,2,3]]), 0, 0, np.array([[4,5,6]])]
array([[1, 2, 3, 0, 0, 4, 5, 6]])
numpy函数白板的更多相关文章
- Numpy函数库基础
利用Numpy函数库构造4*4随机数组,然后将数组转化为矩阵,然后矩阵与其逆矩阵相乘,计算机处理的误差 from numpy import * random.rand(4,4) print(rando ...
- [转]Python numpy函数hstack() vstack() stack() dstack() vsplit() concatenate()
Python numpy函数hstack() vstack() stack() dstack() vsplit() concatenate() 觉得有用的话,欢迎一起讨论相互学习~Follow Me ...
- Numpy 函数总结 (不断更新)
本篇主要收集一些平时见到的 Numpy 函数. numpy.random.seed & numpy.random.RandomState np.random.seed() 和 np.rando ...
- numpy函数库中一些经常使用函数的记录
##numpy函数库中一些经常使用函数的记录 近期才開始接触python,python中为我们提供了大量的库,不太熟悉.因此在<机器学习实战>的学习中,对遇到的一些函数的使用方法进行记录. ...
- numpy函数库中一些常用函数的记录
##numpy函数库中一些常用函数的记录 最近才开始接触Python,python中为我们提供了大量的库,不太熟悉,因此在<机器学习实战>的学习中,对遇到的一些函数的用法进行记录. (1) ...
- numpy函数笔记(持续更新)
numpy函数笔记 np.isin用法 np.isin(a,b) 用于判定a中的元素在b中是否出现过,如果出现过返回True,否则返回False,最终结果为一个形状和a一模一样的数组.(注意:这里的a ...
- numpy 函数一:linspace
接触 numpy 遇到的第一个函数可能就是 linspace 函数,但是对于我们这种没有学过 matlab 的人来说,根本不知道这是什么. 所以只能自己查资料. 词典显示: 线性等分向量 线性平分矢量 ...
- numpy函数fromfunction分析
从函数规则创建数组是非常方便的方法.在numpy中我们常用fromfunction函数来实现这个功能. 在numpy的官网有这么一个例子. >>> def f(x,y): ... r ...
- Python numpy函数hstack() vstack() stack() dstack() vsplit() concatenate()
感觉numpy.hstack()和numpy.column_stack()函数略有相似,numpy.vstack()与numpy.row_stack()函数也是挺像的. stackoverflow上也 ...
随机推荐
- 【003:jsoncpp的简单使用】
#include <json/json.h> #include <iostream> #include <string> using namespace std; ...
- C语言回顾-字符串指针
1.字符串指针 char *变量名="字符串内容"; char ch='b'; char *p1=&ch; char *str="C Language" ...
- Install Mono on Linux
Debian, Ubuntu, and derivatives Add the Mono Project GPG signing key and the package repository to y ...
- Web Word和Excel
暂时收集点资料备用 Excel http://www.cnblogs.com/downmoon/archive/2011/05/30/2063258.html http://www.cnblogs.c ...
- python常用小模块使用汇总
在写代码过程中常用到一些好用的小模块,现整理汇总一下: 1.获取当前的文件名和目录名,并添到系统环境变量中. file = os.path.abspath(__file__) ...
- Linux-wget
Linux系统中的wget是一个下载文件的工具,它用在命令行下.对于Linux用户是必不可少的工具,我们经常要下载一些软件或从远程服务器恢复备份到本地服务器.wget支持HTTP,HTTPS和FTP协 ...
- style设置/获取样式的问题 和 offsetWidth/offsetHeight的问题
style设置/获取样式的问题:1.js通过style方法 --加样式:加的是行间样式 oDiv.style.width="20"+'px'; --取样式:取得是行间样 ...
- TOJ 2776 CD Making
TOJ 2776题目链接http://acm.tju.edu.cn/toj/showp2776.html 这题其实就是考虑的周全性... 贡献了好几次WA, 后来想了半天才知道哪里有遗漏.最大的问题 ...
- js 判断移动设备、pc端、android、iPhone、是否为微信、微博、qq空间
varbrowser = { versions: function () { var u = navigator.userAgent, app = navigator.appVersio ...
- webpack react基础配置一
简单介绍webpack react基本配置,入门型: 环境配置: 依赖nodejs,官网下载最新版的nodejs:nodejs.org/en 安装完nodejs npm便自动集成了,通过npm安装其 ...