Python笔记 #07# NumPy 文档地址 & Subsetting 2D Arrays
文档地址: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的更多相关文章
- 使用sphinx快速为你python注释生成API文档
sphinx简介sphinx是一种基于Python的文档工具,它可以令人轻松的撰写出清晰且优美的文档,由Georg Brandl在BSD许可证下开发.新版的Python3文档就是由sphinx生成的, ...
- 使用sphinx为python注释生成docAPI文档
sphinx简介 sphinx是一种基于Python的文档工具,它可以令人轻松的撰写出清晰且优美的文档,由Georg Brandl在BSD许可证下开发. 新版的Python3文档就是由sphinx生成 ...
- python快速生成注释文档的方法
python快速生成注释文档的方法 今天将告诉大家一个简单平时只要注意的小细节,就可以轻松生成注释文档,也可以检查我们写的类方法引用名称是否重复有问题等.一看别人专业的大牛们写的文档多牛多羡慕,不用担 ...
- 找到python官方标准库文档
python中有很多标准库.我们没法记住全部标准库,但是可以在:https://docs.python.org/3/py-modindex.html 中查看标准库的索引 在python的官方文档中,如 ...
- python常用模块-配置文档模块(configparser)
python常用模块-配置文档模块(configparser) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. ConfigParser模块用于生成和修改常见配置文档,当前模块的名称 ...
- EXTJS文档地址
文档地址:http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.form.field.Field-event-change
- 【Swagger2】解决swagger文档地址请求404的问题
一.出现的问题背景 某个项目,本地启动后,访问swagger文档地址可以访问到, http://localhost:8203/doc.html.但是部署到开发环境就访问不到,报404资源找不到的问题 ...
- VMware vSphere ESXi 和 vCenter Server 5.1 文档地址
VMware vSphere ESXi 和 vCenter Server 5.1 文档地址 https://pubs.vmware.com/vsphere-51/index.jsp?top ...
- hugo官方相关文档地址
+++ date="2020-10-17" title="hugo官方相关文档地址" tags=["hugo"] categories=[& ...
随机推荐
- stm32入门(从51过渡到32)
单片机对于我来说,就是一个超级大机器,上面有一排一排数不尽的开关,我需要做的,就是根据我的设计,拿着一张超级大的表(Datasheet),把需要的开关(reg)都开关(config)到对应功能的位置( ...
- 怎样安装Linux操作系统
linux是免费的.其实这里的免费只是说linux的内核免费.在linux内核的基础上而产生了众多linux的版本.Linux的发行版说简单点就是将Linux内核与应用软件做一个打包.较知名的发行版有 ...
- Oracle分页查询sql语句
1. select * from ( select t.*, rownum RN from TABLE_NAME t ) where RN > 0 and RN <= 15 2. se ...
- poj_2709 贪心算法
poj 2709 painter 题目要求 给定涂料,每套涂料含有3-12种不同的颜色(开始时候给定选用的颜料套的颜色数目),且一套涂料中每种颜色均有50ml.且一套涂料中的任意三种不同的颜色各X m ...
- poj_1037 动态规划+字典序第k大
题目大意 给定n个数字,规定一种 cute 排序:序列中的数字大小为严格的波浪形,即 a[0] > a[1] < a[2] > a[3] < .... 或者 a[0] < ...
- 2015.10.11(js判断鼠标进入容器的方向)
判断鼠标进入容器的方向 1.前几天在万圣节专题项目中用到了鼠标坐标page事件,随着鼠标背景图片移动形成有层次感的效果,但page事件在IE低版本不支持,所以还要做兼容.在研究page事件同时无意中想 ...
- Eclipse打包Egret App (Egret4.1.0)
Egret官方提供eclipse和androidstudio打包. 这里使用eclipse. 1 下载配置android环境 2 Egret打包App 3 Eclipse设置 4 Eclipse调试 ...
- java如何计算两个日期之间相差多少天?
java如何计算两个日期之间相差多少天? public static void main(String [] args) { Date now = new Date(); Calendar cal = ...
- 2-sat+二分搜索hdu(3622)
hdu3622 Bomb Game Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Floyd算法并输出路径
hdu1224 Free DIY Tour Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...