numpy.concatenate()函数沿着现有轴连接一系列数组。
用法: numpy.concatenate((arr1, arr2, …), axis=0, out=None)
参数:
arr1, arr2, … :[sequence of array_like] The arrays must have the same shape, except in the dimension corresponding to axis.
axis :[int, optional] The axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.
out :[ndarray, optional] If provided, the destination to place the result. The shape must be correct, matching that of what concatenate would have returned if no out argument were specified.
Return :[ndarray] The concatenated array.
代码1:
# Python program explaining
# numpy.concatenate() function
# importing numpy as geek
import numpy as geek
arr1 = geek.array([[2, 4], [6, 8]])
arr2 = geek.array([[3, 5], [7, 9]])
gfg = geek.concatenate((arr1, arr2), axis = 0)
print (gfg)
输出:
[[2 4] [6 8] [3 5] [7 9]]
代码2:
# Python program explaining
# numpy.concatenate() function
# importing numpy as geek
import numpy as geek
arr1 = geek.array([[2, 4], [6, 8]])
arr2 = geek.array([[3, 5], [7, 9]])
gfg = geek.concatenate((arr1, arr2), axis = 1)
print (gfg)
输出:
[[2 4 3 5] [6 8 7 9]]
代码3:
# Python program explaining
# numpy.concatenate() function
# importing numpy as geek
import numpy as geek
arr1 = geek.array([[2, 4], [6, 8]])
arr2 = geek.array([[3, 5], [7, 9]])
gfg = geek.concatenate((arr1, arr2), axis = None)
print (gfg)
输出:
[2 4 6 8 3 5 7 9]
相关用法
- Python Wand function()用法及代码示例
- Python map()用法及代码示例
- Python tell()用法及代码示例
- Python dir()用法及代码示例
- Python cmp()用法及代码示例
- Python oct()用法及代码示例
- Python ord()用法及代码示例
- Python hex()用法及代码示例
- Python str()用法及代码示例
- Python sum()用法及代码示例
- Python min()用法及代码示例
- Python int()用法及代码示例
- Python id()用法及代码示例
- Python now()用法及代码示例
- Python frexp()用法及代码示例
- Python math.cos()用法及代码示例
注:本文由纯净天空筛选整理自sanjoy_62大神的英文原创作品 numpy.concatenate() function | Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。