串联是指连接,此函数用于沿指定轴连接两个或多个相同维度的数组。该函数采用以下参数。
numpy.concatenate((a1, a2, ...), axis)
Sr.No. | Parameter & 描述 |
---|---|
1 | a1,a2 .. 相同类型的数组序列 |
2 | axis 必须沿其连接数组的轴。默认为0 |
import numpy as np a = np.array([[1,2],[3,4]]) print 'First array:' print a print '\n' b = np.array([[5,6],[7,8]]) print 'Second array:' print b print '\n' # both the arrays are of same dimensions print 'Joining the two arrays along axis 0:' print np.concatenate((a,b)) print '\n' print 'Joining the two arrays along axis 1:' print np.concatenate((a,b),axis = 1)
其输出如下-
链接:https://www.learnfk.comhttps://www.learnfk.com/numpy/numpy-concatenate.html
来源:LearnFk无涯教程网
First array: [[1 2] [3 4]] Second array: [[5 6] [7 8]] Joining the two arrays along axis 0: [[1 2] [3 4] [5 6] [7 8]] Joining the two arrays along axis 1: [[1 2 5 6] [3 4 7 8]]
这一章《NumPy - 数组操作 - concatenate函数》你学到了什么?在下面做个笔记吧!做站不易,你的分享是对我们最大的支持
错误:在 dd/mm/yyyy 的字符串格式化期间并非所有参数都转换了
如何在 python 中过滤 .json 数组,以便每个元素中只显示一个参...
如何在 Databricks Delta Live 表上使用 Apache Sedona?
将 pandasql 输出分配给 DataFrame 中的新列
在 Pandas 中的列之间搜索范围内的值(不是日期列和没有 sql)