NumPy Reference: Indexing

Note: Indexing starts at 0 (zero).

def slicing():
a = np.random.rand(5,4)
print(a)
"""
[[ 0.15372787 0.83347785 0.86855635 0.23592008]
[ 0.74925447 0.08453883 0.62021973 0.51972556]
[ 0.33835541 0.03772665 0.53220179 0.2095391 ]
[ 0.41991738 0.76028856 0.22081936 0.4240198 ]
[ 0.93666236 0.72688287 0.99309427 0.69388106]]
"""
print(a[0:2, 0:4:3]) #0:4:3 X:Y:Z, if Y > Z, z is step, so here is take columns from [0,4), step is 3
"""
   [[ 0.15372787 0.23592008]
[ 0.74925447 0.51972556]]
""" if __name__ == "__main__": slicing()

[Python] Accessing Array Elements的更多相关文章

  1. 【LeetCode】453. Minimum Moves to Equal Array Elements 解题报告(Java & Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:模拟过程 方法二:求和-n*最小值 方法三: ...

  2. 【LeetCode】462. Minimum Moves to Equal Array Elements II 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:排序 方法二:直接找中位数 日期 题目地址: ...

  3. [LeetCode&Python] Problem 453. Minimum Moves to Equal Array Elements

    Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...

  4. 【LeetCode】462. Minimum Moves to Equal Array Elements II

    Given a non-empty integer array, find the minimum number of moves required to make all array element ...

  5. 462. Minimum Moves to Equal Array Elements II

    Given a non-empty integer array, find the minimum number of moves required to make all array element ...

  6. [LeetCode] Minimum Moves to Equal Array Elements II 最少移动次数使数组元素相等之二

    Given a non-empty integer array, find the minimum number of moves required to make all array element ...

  7. [LeetCode] Minimum Moves to Equal Array Elements 最少移动次数使数组元素相等

    Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...

  8. LeetCode Minimum Moves to Equal Array Elements II

    原题链接在这里:https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/ 题目: Given a non-empt ...

  9. LeetCode Minimum Moves to Equal Array Elements

    原题链接在这里:https://leetcode.com/problems/minimum-moves-to-equal-array-elements/ 题目: Given a non-empty i ...

随机推荐

  1. Swift 中的协议

    Swift 中的协议协议是为方法.属性等定义一套规范,没有具体的实现,类似于Java中的抽象接口,它只是描述了方法或属性的骨架,而不是实现.方法和属性实现还需要通过定义类,函数和枚举完成. 协议定义 ...

  2. No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with name 'SpringMVC'

    控制台一直报No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with na ...

  3. LightOJ-1220 Mysterious Bacteria 唯一分解定理 带条件的最大公因数

    题目链接:https://cn.vjudge.net/problem/LightOJ-1220 题意 给x=y^p,问p最大多少 注意x可能负数 思路 唯一分解定理,求各素因数指数的GCD 注意负数的 ...

  4. Linux 程序包管理-RPM

    程序简介:  POSIX(Portable Openratin System)跨平台系统:不同操作系统平台的标准C库(glibc)都是遵循POSIX规范的,这样基于标准库开发程序的源代码可以夸平台编译 ...

  5. Linux Shell脚本编程-信号捕获

    bash编程的信号捕获:  kill -l 显示当前系统可用信号(trap -l)  获取帮助:man 7 single 常用信号: 1) SIGHUP  无须重启进程而让其重读配置文件  2) SI ...

  6. 【转】Hook钩子C#实例

    [转]Hook钩子C#实例 转过来的文章,出处已经不知道了,但只这篇步骤比较清晰,就贴出来了. 一.写在最前 本文的内容只想以最通俗的语言说明钩子的使用方法,具体到钩子的详细介绍可以参照下面的网址: ...

  7. 一个tomcat下部署多个项目或一个服务器部署多个tomcat

    最近需要把两个项目同时部署到服务器上,于是研究了一下,页借鉴了很多别人的方法,把过程记录下来,以儆效尤. 目录: 1,一个tomcat下同时部署两个项目(多个项目可以参考) 1.1项目都放在webap ...

  8. Qt 3D教程(二)初步显示3D的内容

    Qt3D教程(二)初步显示3D的内容 前一篇很easy,全然就没有牵涉到3D的内容,它仅仅是我们搭建3D应用的基本框架而已,而这一篇.我们将要利用它来初步地显示3D的内容了! 本次目的是将程序中间的内 ...

  9. css中使用id和class 的不同

    在 CSS 中,类选择器以一个点号显示: .center {text-align: center} 在上面的样例中,全部拥有 center 类的 HTML 元素均为居中. 在以下的 HTML 代码中, ...

  10. 7、java封装、继承、聚合组合

    1封装:封装的是属性,封:private 装:set.get‘ 可以看做将属性和get/set方法捆绑的过程. 优点:1.防止对封装数据的未经授权的访问,提高安全性.使用者只能通过事先预定好的方法来访 ...