python append不适用于2d数组中的axis=1

evrscar2  于 2021-07-13  发布在  Java
关注(0)|答案(1)|浏览(199)

python append不适用于2d数组中的axis=1。

  1. import numpy as np
  2. TwoDArray = np.array([[11, 15, 10, 6],
  3. [10, 14, 11, 5],
  4. [12, 17, 12, 8],
  5. [15, 18, 14, 9]])
  6. print(TwoDArray)
  7. new2d = np.append(TwoDArray, [[1,2,3,4]], axis=1) #this line of code has the problem
  8. print(new2d)
of1yzvn4

of1yzvn41#

  1. new2d = np.append(TwoDArray, [[1,2,3,4]], axis=0)
  2. new2d
  3. array([[11, 15, 10, 6],
  4. [10, 14, 11, 5],
  5. [12, 17, 12, 8],
  6. [15, 18, 14, 9],
  7. [ 1, 2, 3, 4]])

相关问题