📜  numpy.concatenate()函数| Python

📅  最后修改于: 2022-05-13 01:55:38.804000             🧑  作者: Mango

numpy.concatenate()函数| Python

numpy.concatenate()函数沿现有轴连接一系列数组。

代码#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]