How do you extract a column from a multi-dimensional array?

前端 未结 20 2917
感情败类
感情败类 2020-12-02 03:56

Does anybody know how to extract a column from a multi-dimensional array in Python?

20条回答
  •  广开言路
    2020-12-02 04:21

    If you want to grab more than just one column just use slice:

     a = np.array([[1, 2, 3],[4, 5, 6],[7, 8, 9]])
        print(a[:, [1, 2]])
    [[2 3]
    [5 6]
    [8 9]]
    

提交回复
热议问题