[Python] Python: slicing a multi-dimensional array

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I know how to slice 1-dimensional sequence: arr[start:end], and access an element in the array: el = arr[row][col].

    Now, I'm trying something like slice = arr[0:2][0:2] (where arr is a numpy array) but it doesn't give me the first 2 rows and columns, but repeats the first 2 rows. What did I just do, and how do I slice along another dimension?

    Continue reading...

Compartilhe esta Página