文档地址:np.array()

1、<class 'numpy.ndarray'>

ndarray 表示 n 维度(n D)数组 (= n 行数组)。

2、打印 array 结构 —— np_array.shape

3、Subsetting 2D Arrays 的两种方式

不管是 arr[1][2] 还是 arr[1,2] 都是可行的,不过教程推荐第二种方式。

4、代码演示 & 一个取子集的小技巧

创建:

# Create baseball, a list of lists
baseball = [[180, 78.4],
[215, 102.7],
[210, 98.5],
[188, 75.2]] # Import numpy
import numpy as np # Create a 2D numpy array from baseball: np_baseball
np_baseball = np.array(baseball) # Print out the type of np_baseball
print(type(np_baseball)) # Print out the shape of np_baseball
print(np_baseball.shape)

打印结构:

# baseball is available as a regular list of lists

# Import numpy package
import numpy as np # Create a 2D numpy array from baseball: np_baseball
np_baseball = np.array(baseball) # Print out the shape of np_baseball
print(np_baseball.shape)

小技巧:

# baseball is available as a regular list of lists

# Import numpy package
import numpy as np # Create np_baseball (2 cols)
np_baseball = np.array(baseball) # Print out the 50th row of np_baseball
print(np_baseball[49,:]) # Select the entire second column of np_baseball: np_weight
np_weight = np_baseball[:,1] # Print out height of 124th player
print(np_baseball[123,0])

5、整体数学运算

# baseball is available as a regular list of lists
# updated is available as 2D numpy array # Import numpy package
import numpy as np # Create np_baseball (3 cols)
np_baseball = np.array(baseball) # Print out addition of np_baseball and updated
print(np_baseball + updated) # Create numpy array: conversion
conversion = np.array([0.0254, 0.453592, 1]) # Print out product of np_baseball and conversion
print(conversion * np_baseball)

Python笔记 #07# NumPy 文档地址 & Subsetting 2D Arrays的更多相关文章

  1. 使用sphinx快速为你python注释生成API文档

    sphinx简介sphinx是一种基于Python的文档工具,它可以令人轻松的撰写出清晰且优美的文档,由Georg Brandl在BSD许可证下开发.新版的Python3文档就是由sphinx生成的, ...

  2. 使用sphinx为python注释生成docAPI文档

    sphinx简介 sphinx是一种基于Python的文档工具,它可以令人轻松的撰写出清晰且优美的文档,由Georg Brandl在BSD许可证下开发. 新版的Python3文档就是由sphinx生成 ...

  3. python快速生成注释文档的方法

    python快速生成注释文档的方法 今天将告诉大家一个简单平时只要注意的小细节,就可以轻松生成注释文档,也可以检查我们写的类方法引用名称是否重复有问题等.一看别人专业的大牛们写的文档多牛多羡慕,不用担 ...

  4. 找到python官方标准库文档

    python中有很多标准库.我们没法记住全部标准库,但是可以在:https://docs.python.org/3/py-modindex.html 中查看标准库的索引 在python的官方文档中,如 ...

  5. python常用模块-配置文档模块(configparser)

    python常用模块-配置文档模块(configparser) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. ConfigParser模块用于生成和修改常见配置文档,当前模块的名称 ...

  6. EXTJS文档地址

    文档地址:http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.form.field.Field-event-change

  7. 【Swagger2】解决swagger文档地址请求404的问题

    一.出现的问题背景 某个项目,本地启动后,访问swagger文档地址可以访问到, http://localhost:8203/doc.html.但是部署到开发环境就访问不到,报404资源找不到的问题 ...

  8. VMware vSphere ESXi 和 vCenter Server 5.1 文档地址

    VMware vSphere ESXi 和 vCenter Server 5.1 文档地址       https://pubs.vmware.com/vsphere-51/index.jsp?top ...

  9. hugo官方相关文档地址

    +++ date="2020-10-17" title="hugo官方相关文档地址" tags=["hugo"] categories=[& ...

随机推荐

  1. php检测文件只读、可写、可执行权限

    例子:检测文件是否可读.可写.可执行. 复制代码代码示例: <?php  $myfile = "./test.txt"; if (is_readable ($myfile)) ...

  2. ajax返回值传给js全局变量

    1. $.ajaxSetup({ async : false //设置ajax为同步方式,异步方式的话在赋值时数据还未提取出来 });var t = ""; var enginee ...

  3. 使用Sublime Text 3做Python开发

    引言 刚转到OS X平台时,寻找写Python,JavaScript,Markdown等文件的工具时,比较了许多工具, 最终选择了Sublime Text 2,主要原因是其跨平台, 想着以后再转到wi ...

  4. 1948 NOI 嘉年华

    1948 NOI 嘉年华 2011年NOI全国竞赛  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 大师 Master 题解  查看运行结果     题目描述 Descript ...

  5. Mac - 苹果电脑mac系统释放硬盘空间方法汇总

    硬盘空间是大家最头痛的一个问题,大家在硬盘空间变小的时候怎么腾空间的呢?下面为大家分享7个mac系统释放空间的高级方法,大家赶紧来收了! mac系统释放硬盘空间方法: 方法一:删除Emacs--可以节 ...

  6. (贪心)kruskal思想

    hdu4313 Matrix Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  7. 阿里云ecs禁止ping,禁止telnet

    现在的中小型企业服务器大多是云比较多,因此,可能会面临着服务器ping不通,或者是端口telnet不通的情况,但是服务器上的服务仍然是正常的情况,这个时候我们就要考虑是不是云上配置了访问规则了.废话不 ...

  8. 百度输入法引起的Mac远程桌面Ctrl+.快捷键不起作用

    被这个问题困扰已久!在Mac中通过远程桌面(Remote Desktop)连接至Windows服务器时,Ctrl+.快捷键不起作用,而这是用Visual Studio写代码时常用的快捷键(对应的命令是 ...

  9. python bug the C library strftime function.

    import timedef date2mktime(date, format_='%Y-%m-%d'): return int(time.mktime(time.strptime(date, for ...

  10. code sandbox & mlflow

    https://codesandbox.io/ https://www.jianshu.com/p/d70b25bf3cf4 https://my.oschina.net/u/2306127/blog ...