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. LR编写post请求

    函数列表: web_submit_data(); web_custom_request(); web_get_int_property(); 1.web_submit_data(); 2.web_cu ...

  2. 将对象a的属性赋值给对象b

    BeanUtils.copyProperties(a,b); 将a的属性赋值给b(ab的共同属性)

  3. [ZJOI2015]幻想乡战略游戏(点分树)

    题意自己看... 思路 没想到今(昨)天刷着刷着点分治的水题,就刷出来了一个点分树... 然后就疯狂地找题解,代码,最后终于把它给弄懂了. 点分树——动态点分治,对于此题来说,我们设u为当前的补给站位 ...

  4. java 导出百万数据到excel

    @RequestMapping("export") public void write(HttpServletRequest request,HttpServletResponse ...

  5. java zyUpload 实现多文件上传

    1.html部分 <form enctype="multipart/form-data"> <label>请选择文件</label> <i ...

  6. malloc 和free例程

    #include <stdio.h>#include <stdlib.h>int main(){int a;scanf("%d",&a);int * ...

  7. 第一个JavaWeb工程

    这个工程主要用来研究log4j,所以就只有一个页面,希望以后慢慢进步. java动态生成网页主要使用servlet.把请求拦截下来,处理后返回结果. 这里创建的是一个maven工程. 结构如下:

  8. 【BZOJ 1196】[HNOI2006]公路修建问题

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 二分最后选的边中的最大值是多少. mid 则所有边权小于等于mid的边都可以用了. 那么我们要怎么选择呢? ->优先选择一级的 ...

  9. Matlab 图像的邻域和块操作

    图像的邻域操作是指输出图像的像素点取值,由输入图像的某个像素点及其邻域内的像素,通常像素点的邻域是一个远小于图像本身尺寸.形状规则的像素块,如2×2,3×3正方形.2×3矩形等,或者近似圆形的多边形. ...

  10. Linux 进程间通信(IPC)

    Linux 进程间通信(IPC): Linux系统中除了进程和进程之间通信,我想大家也应该关注用户空间与内核空间是怎样通信的.例如说netlink等等. 除了传统进程间通信外像Socket通信也须要掌 ...