Python Numpy Tutorials: 数组--4
来源:互联网 发布:淘宝名字叫什么好 编辑:程序博客网 时间:2024/06/17 04:56
# -*- coding: utf-8 -*-"""Python Version: 3.5Created on Thu May 11 14:42:49 2017E-mail: Eric2014_Lv@sjtu.edu.cn@author: DidiLv"""import numpy as npa = np.array([[1,2], [3, 4], [5, 6]])# 寻找元素大于2的值,并且返回其bool值bool_idx = (a > 2) # Find the elements of a that are bigger than 2; # this returns a numpy array of Booleans of the same # shape as a, where each slot of bool_idx tells # whether that element of a is > 2.print(bool_idx) # Prints "[[False False] # [ True True] # [ True True]]"# We use boolean array indexing to construct a rank 1 array# consisting of the elements of a corresponding to the True values# of bool_idxprint(a[bool_idx]) # Prints "[3 4 5 6]"# We can do all of the above in a single concise statement:print(a[a > 2]+10) # Prints "[13 14 15 16]"
0 0
- Python Numpy Tutorials: 数组--4
- Python Numpy Tutorials: 数组
- Python Numpy Tutorials: 数组--1
- Python Numpy Tutorials: 数组--2
- Python Numpy Tutorials: 数组--3
- Python Numpy Tutorials: 改变数组的维度
- Python Numpy Tutorials: 集合
- Python Numpy Tutorials: 函数
- Python Numpy Tutorials: 类
- Python Numpy Tutorials: 数据类型
- Python Numpy Tutorials: Broadcasting
- Python Numpy Tutorials: 元组
- Python Numpy Tutorials: 数组乘法:点乘和矩阵(数组)乘法
- Python Numpy Tutorials: 数组中数学函数及变形(reshape)
- Python Scipy&NUmpy Tutorials:Scipy与Matplot
- Python Numpy数组保存
- Python Numpy数组保存
- Python Numpy数组保存
- Markdown 概识——优缺点
- 应对市场汹涌变革 你需要服装BI解决方案
- array_change_key_case函数
- Zookeeper系列(四)Zookeeper客户端(JAVA)API之创建会话
- AIDL解析
- Python Numpy Tutorials: 数组--4
- Http协议相关知识
- WP_使用_FastCGI_Cache_实现高效页面缓存
- ReactiveCocoa学习篇——【上】
- 01背包问题python实现
- CentOS7下内核源码下载及编译步骤
- 如何避免SSH Secure Shell Client连接Linux超时,自动断开?
- 编程实现strcpy和memcpy函数
- android经常性错误解决