Personal website Rudolf Adamkovič

Home / NumPy


Pre-filling: np.<empty|zeros|ones|full>[_like]

  • filled with garbage (not clearing memory, fastest)
    • np.empty(SHAPE, dtype=float64)
    • np.empty_like(ARRAY)
  • filled with 0s
    • np.zeros(SHAPE, dtype=float64)
    • np.zeros_like(ARRAY)
  • filled with 1s
    • np.ones(SHAPE, dtype=float64)
    • np.ones_like(ARRAY)
  • filled with VALUE
    • np.full(SHAPE, VALUE, dtype=DTYPE)
    • np.full_like(ARRAY, VALUE)
import numpy as np
a = np.zeros((4, 4), dtype = np.int64)
a
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])


© 2025 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and secret alien technologies of yesteryear.