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=[& ...
随机推荐
- 谈谈KV存储集群的设计要点
版权声明:本文由廖念波原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/150 来源:腾云阁 https://www.qclo ...
- nodejs 事件EventEmitter
index.js: // 引入 events 模块 var events = require('events'); //处理函数要写在调用前 var eventHandler = function() ...
- [分享]收集的Linux学习资源
下面是我收集的一些Linux资源,与大家分享.大家共同学习,一起进步. 国内的专业Linux网站(GB) 1. ChinaUnix:http://www.chinaunix.net/ 2. Linux ...
- C++ 初始化函数的实现
http://www.cppblog.com/xlshcn/archive/2007/11/21/37088.aspx
- 【BZOJ4195】[Noi2015]程序自动分析 并查集
[BZOJ4195][Noi2015]程序自动分析 Description 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2,x3 ...
- SQL中distinct的用法(转载)
1.作用于单列 2.作用于多列 3.COUNT统计 4.distinct必须放在开头 5.其他 在表中,可能会包含重复值.这并不成问题,不过,有时您也许希望仅仅列出不同(distinct)的值.关键词 ...
- 160227、javascript特效
1.给网页设定快捷键 js: function getkey(){ event = event || window.event; url = "www.baidu.com&q ...
- Oracle SQL开发 之 Select语句完整的执行顺序
查询语句语法: Select 属性 From 表 Where 条件 Group by 分组条件 Having 分组选择条件 Order by 排序条件 1.from子句组装来自不同数据源的数据: 2. ...
- apache代理weblogic集群办法
方法一: --关闭iptables和selinux --在apache配置文件httpd.conf最下面添加如下语句,然后重启apache: ServerName 127.0.0.1:80 NameV ...
- 白话陈述之——从python脚本变化解析由路径引起的GP服务运行失败问题
补充一下未完待续的利用Python分析GP服务运行结果的输出路径 & 实现服务输出路径的本地化,这篇博客中主要介绍了如何实现将GP服务生成的结果输出至本地及输入输出路径导致GP服务运行失败的问 ...