numpy split()
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, foraxis=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()的更多相关文章
- NumPy 学习笔记(三)
NumPy 数组操作: 1.修改数组形状 a.numpy.reshape(arr, newshape, order='C') 在不改变数据的条件下修改形状 b.numpy.ndarray.flat 是 ...
- Numpy学习笔记(二)
(1)NumPy - 切片和索引 l ndarray对象中的元素遵循基于零的索引. 有三种可用的索引方法类型: 字段访问,基本切片和高级索引. l 基本切片 Python 中基本切片概念到 n 维 ...
- Numpy 数组操作
Numpy 数组操作 Numpy 中包含了一些函数用于处理数组,大概可分为以下几类: 修改数组形状 翻转数组 修改数组维度 连接数组 分割数组 数组元素的添加与删除 修改数组形状 函数 描述 resh ...
- python之numpy的基本使用
https://blog.csdn.net/cxmscb/article/details/54583415 一.numpy概述 numpy(Numerical Python)提供了python对多维数 ...
- Python Numpy Array
Numpy 是Python中数据科学中的核心组件,它给我们提供了多维度高性能数组对象. Arrays Numpy.array dtype 变量 dtype变量,用来存放数据类型, 创建数组时可以同 ...
- Python之Numpy详细教程
NumPy - 简介 NumPy 是一个 Python 包. 它代表 “Numeric Python”. 它是一个由多维数组对象和用于处理数组的例程集合组成的库. Numeric,即 NumPy 的前 ...
- Numpy | 12 数组操作
Numpy 中包含了一些函数用于处理数组,大概可分为以下几类: 修改数组形状 翻转数组 修改数组维度 连接数组 分割数组 数组元素的添加与删除 一.修改数组形状 函数 描述 reshape 不改变数据 ...
- 9、numpy——数组操作
Numpy 中包含了一些函数用于处理数组,大概可分为以下几类: (1)修改数组形状 (2)翻转数组 (3)修改数组维度 (4)连接数组 (5)分割数组 (6)数组元素的添加与删除 1.修改数组形状 函 ...
- Kaggle新手入门之路
学完了Coursera上Andrew Ng的Machine Learning后,迫不及待地想去参加一场Kaggle的比赛,却发现从理论到实践的转变实在是太困难了,在此记录学习过程. 一:安装Anaco ...
随机推荐
- drupal中文安装指导
(注:drupal6中文包放在profiles/default/translations下,drupal7放在profiles/standard/translations下) Drupal 6 中文安 ...
- 1、Centos7 python2.7和yum完全卸载及重装
完全重装python和yum 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1.删除现有Python ...
- win10下vs2013为程序集新建强名称文件时“未能完成操作。拒绝访问”的解决方案
昨日,在使用vs2013开发开发一个小工具,打算给这个小工具的源代码进行保护. 在输入完成建立强名称密钥文件时,爆出了如下错误: 一开始以为是项目所在路径的权限问题,于是给项目所在路径文件夹添加了“U ...
- 分布式系统中的CAP原理和BASE理论
CAP是一致性(Consistency).可用性(Availability).分区容忍性(Partition tolerance)的缩写.CAP原理指的是这三个要素最多只能同时实现两点,不可能三者兼顾 ...
- The Jaisalmer Desert Festival 2017/2/9
原文 India's Golden City celebrates its culture with costumes(服装),crafts(工艺品) and camels One of the fe ...
- codevs 2618 核电站问题
时间限制: 1 s 空间限制: 32000 KB 题目等级 : 黄金 Gold 题目描述 Description 一个核电站有N个放核物质的坑,坑排列在一条直线上.如果连续M个坑中放入核物质,则会 ...
- NoSuchBeanDefinitionException: No qualifying bean of type 'com.bj186.ssm.mapper.EmployeeMapper' available: expected at least 1 bean which qualifies as autowire candidate
在搭建SSM spring springmvc mybatis整合的时候, 遇到了这个问题 说说我的问题吧!我在进行单元测试的时候,出现了这个错误,网上一查才知道是,配置文件中没有写扫描包信息.一看 ...
- 两个input标签之间间隙问题的解决
<input type="text"> <input type="button" value="搜索"> 代码显示效 ...
- shell脚本,用awk实现替换文件里面的内容。
文件是这样,有ID和具体信息,ID行以@开头,后面的信息有空格,把第一个空格后的全部内容替换为空格前的字符. 用AWK来实现. @AA10 P 7 #YYYYYYYYYYYYYYYYYYZZZZZZZ ...
- Spring框架xml配置文件 复杂类型属性注入——数组 list map properties DI dependency injection 依赖注入——属性值的注入依赖于建立的对象(堆空间)
Person类中的各种属性写法如下: package com.swift.person; import java.util.Arrays; import java.util.List; import ...