冉冉说
您可以使用np.delete删除多余的列然后使用np.concatenateheaders = list('abcdefghik')a = np.arange(len(headers)).reshape(1, -1)#Output: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])headers_2 = list('abcdefghijk')b = np.arange(len(headers_2)*2).reshape(2,-1)#Output: array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],# [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]])col_to_remove = headers_2.index('j')np.delete(b, col_to_remove, axis = 1) #note that this does not modify original array, returns a copy.#Output: array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10],# [11, 12, 13, 14, 15, 16, 17, 18, 19, 21]])result = np.concatenate((a, np.delete(b, col_to_remove, axis = 1)))#Output: array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],# [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10],# [11, 12, 13, 14, 15, 16, 17, 18, 19, 21]])