1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Zero pad numpy array

Discussão em 'Python' iniciado por Stack, Agosto 12, 2025.

  1. Stack

    Stack Membro Participativo

    What's the more pythonic way to pad an array with zeros at the end?

    def pad(A, length):
    ...

    A = np.array([1,2,3,4,5])
    pad(A, 8) # expected : [1,2,3,4,5,0,0,0]


    In my real use case, in fact I want to pad an array to the closest multiple of 1024. Ex: 1342 => 2048, 3000 => 3072

    Continue reading...

Compartilhe esta Página