numpy.split(ary, indices_or_sections, axis=0)[source]

Split an array into multiple sub-arrays.

将一个array分成多个子array

Parameters:

ary : ndarray

Array to be divided into sub-arrays.

indices_or_sections : int or 1-D array

If indices_or_sections is an integer, N, the array will be divided into N equal arrays along axis. If such a split is not possible, an error is raised.

If indices_or_sections is a 1-D array of sorted integers, the entries indicate where along axis the array is split. For example, [2, 3] would, for axis=0, result in

  • ary[:2]
  • ary[2:3]
  • ary[3:]

If an index exceeds the dimension of the array along axis, an empty sub-array is returned correspondingly.

axis : int, optional

The axis along which to split, default is 0.

Returns:

sub-arrays : list of ndarrays

A list of sub-arrays.

Raises:

ValueError

If indices_or_sections is given as an integer, but a split does not result in equal division.

See also

array_split
Split an array into multiple sub-arrays of equal or near-equal size. Does not raise an exception if an equal division cannot be made.
hsplit
Split array into multiple sub-arrays horizontally (column-wise).
vsplit
Split array into multiple sub-arrays vertically (row wise).
dsplit
Split array into multiple sub-arrays along the 3rd axis (depth).
concatenate
Join a sequence of arrays along an existing axis.
stack
Join a sequence of arrays along a new axis.
hstack
Stack arrays in sequence horizontally (column wise).
vstack
Stack arrays in sequence vertically (row wise).
dstack
Stack arrays in sequence depth wise (along third dimension).

Examples

>>> x = np.arange(9.0)
>>> np.split(x, 3)
[array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7., 8.])]
>>> x = np.arange(8.0)
>>> np.split(x, [3, 5, 6, 10])
[array([ 0., 1., 2.]),
array([ 3., 4.]),
array([ 5.]),
array([ 6., 7.]),
array([], dtype=float64)]

numpy split()的更多相关文章

  1. NumPy 学习笔记(三)

    NumPy 数组操作: 1.修改数组形状 a.numpy.reshape(arr, newshape, order='C') 在不改变数据的条件下修改形状 b.numpy.ndarray.flat 是 ...

  2. Numpy学习笔记(二)

    (1)NumPy - 切片和索引 l  ndarray对象中的元素遵循基于零的索引. 有三种可用的索引方法类型: 字段访问,基本切片和高级索引. l  基本切片 Python 中基本切片概念到 n 维 ...

  3. Numpy 数组操作

    Numpy 数组操作 Numpy 中包含了一些函数用于处理数组,大概可分为以下几类: 修改数组形状 翻转数组 修改数组维度 连接数组 分割数组 数组元素的添加与删除 修改数组形状 函数 描述 resh ...

  4. python之numpy的基本使用

    https://blog.csdn.net/cxmscb/article/details/54583415 一.numpy概述 numpy(Numerical Python)提供了python对多维数 ...

  5. Python Numpy Array

    Numpy 是Python中数据科学中的核心组件,它给我们提供了多维度高性能数组对象. Arrays Numpy.array   dtype 变量 dtype变量,用来存放数据类型, 创建数组时可以同 ...

  6. Python之Numpy详细教程

    NumPy - 简介 NumPy 是一个 Python 包. 它代表 “Numeric Python”. 它是一个由多维数组对象和用于处理数组的例程集合组成的库. Numeric,即 NumPy 的前 ...

  7. Numpy | 12 数组操作

    Numpy 中包含了一些函数用于处理数组,大概可分为以下几类: 修改数组形状 翻转数组 修改数组维度 连接数组 分割数组 数组元素的添加与删除 一.修改数组形状 函数 描述 reshape 不改变数据 ...

  8. 9、numpy——数组操作

    Numpy 中包含了一些函数用于处理数组,大概可分为以下几类: (1)修改数组形状 (2)翻转数组 (3)修改数组维度 (4)连接数组 (5)分割数组 (6)数组元素的添加与删除 1.修改数组形状 函 ...

  9. Kaggle新手入门之路

    学完了Coursera上Andrew Ng的Machine Learning后,迫不及待地想去参加一场Kaggle的比赛,却发现从理论到实践的转变实在是太困难了,在此记录学习过程. 一:安装Anaco ...

随机推荐

  1. vs 2017注册码 激活码

    Visual Studio 2017(VS2017) 企业版 Enterprise 注册码:NJVYC-BMHX2-G77MM-4XJMR-6Q8QFVisual Studio 2017(VS2017 ...

  2. FastDFS java 辅助类

    package cn.saiz.drkms.task.crack.utils; import java.io.File; import java.io.FileInputStream; import ...

  3. 【R语言进行数据挖掘】回归分析

    1.线性回归 线性回归就是使用下面的预测函数预测未来观测量: 其中,x1,x2,...,xk都是预测变量(影响预测的因素),y是需要预测的目标变量(被预测变量). 线性回归模型的数据来源于澳大利亚的C ...

  4. PHP-PHPExcel用法详解

    以下文章来源:diandian_520 http://blog.csdn.net/diandian_520/article/details/7827038 1.header header(" ...

  5. Node.js 打造实时多人游戏框架

    在 Node.js 如火如荼发展的今天,我们已经可以用它来做各种各样的事情.前段时间UP主参加了极客松活动,在这次活动中我们意在做出一款让“低头族”能够更多交流的游戏,核心功能便是 Lan Party ...

  6. ycsb模板介绍

    #对应的mongodb uri参数等mongodb.url=mongodb://127.0.0.1:27010/test_1 #对应的mongo数据库名称mongodb.database=test_1 ...

  7. 51nod 1212 无向图最小生成树(Kruskal模版题)

    N个点M条边的无向连通图,每条边有一个权值,求该图的最小生成树.   Input 第1行:2个数N,M中间用空格分隔,N为点的数量,M为边的数量.(2 <= N <= 1000, 1 &l ...

  8. The Django Book - 第四章 模板2

    模板(相应)使用的几种方式: 1.使用HttpResponse返回字符串HTML from django.http import HttpResponse def current_datetime(r ...

  9. No-12.函数进阶

    函数进阶 目标 函数参数和返回值的作用 函数的返回值 进阶 函数的参数 进阶 递归函数 01. 函数参数和返回值的作用 函数根据 有没有参数 以及 有没有返回值,可以 相互组合,一共有 4 种 组合形 ...

  10. Quartz监听的端口

    上海移通短信网关:556重庆移动短信网关:557消息中心后台维护服务:558网页订单数据同步服务:559基础数据同步程序:560短信数据扣除服务:565基础数据维护服务:589推送数据抓取服务:222 ...