You can multiply a tuple (n,) by the number of dimensions you want. e.g.:

>>> import numpy as np
>>> N=2
>>> np.zeros((N,)*1)
array([ 0.,  0.])
>>> np.zeros((N,)*2)
array([[ 0.,  0.],
       [ 0.,  0.]])
>>> np.zeros((N,)*3)
array([[[ 0.,  0.],
        [ 0.,  0.]],

       [[ 0.,  0.],
        [ 0.,  0.]]])
Answer from mgilson on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.zeros.html
numpy.zeros — NumPy v2.5 Manual
Return a new array of given shape and type, filled with zeros · Shape of the new array, e.g., (2, 3) or 2
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.zeros.html
numpy.zeros — NumPy v2.6.dev0 Manual
Return a new array of given shape and type, filled with zeros · Shape of the new array, e.g., (2, 3) or 2
Discussions

python - Create arbitrary multidimensional zeros array - Stack Overflow
I need to make a multidimensional array of zeros. For two (D=2) or three (D=3) dimensions, this is easy and I'd use: ... Save this answer. ... Show activity on this post. You can multiply a tuple (n,) by the number of dimensions you want. e.g.: >>> import numpy as np >>> N=2 >>> np.zeros((N,)*1) ... More on stackoverflow.com
🌐 stackoverflow.com
April 26, 2017
python - Numpy zeros 2d array: substituting elements at specific indices - Stack Overflow
For a function I have to write again for CodeSignal, I create an 'empty' matrix with numpy called 'result'. During the course of a for loop, I want to add 1s to certain elements of this zeros matri... More on stackoverflow.com
🌐 stackoverflow.com
February 12, 2020
What is the numpy.zeros() function in Python?
The numpy.zeros() function in Python is a part of the NumPy library, which is widely used for numerical computing in Python. This function is used to create an array filled entirely with zeros. It is particularly useful when you need to initialize an array with a default value of zero before ... More on designgurus.io
🌐 designgurus.io
1
10
June 25, 2024
python - Difference in numpy np.zeros((1,2)) vs np.zeros((2,)) - Stack Overflow
So a 1-dimensional array of size 5 isn't a row or a column, just a 1-dimensional array. When you initialise np.zeros ((1,2)) your first dimension has size 1, and your second size 2, so you get a 1 x 2 matrix with two pairs of brackets. When you call np.zeros((2,)) it's just one dimension of ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
AskPython
askpython.com › python-modules › numpy › numpy-zeros-method-in-python
NumPy zeros() Method in Python - AskPython
August 6, 2022 - As we can see from the output, we get a 2D array with all of the elements as 0. We can also create arrays with heterogeneous data type using the zeros() function in Python. We just need to pass a tuple containing the required information. import ...
🌐
w3resource
w3resource.com › numpy › array-creation › zeros.php
NumPy: numpy.zeros() function - w3resource
April 21, 2026 - In this example, a tuple (3, 2) defines the shape of the array, and np.zeros() creates a 2D array filled with zeros.
🌐
iO Flood
ioflood.com › blog › np-zeros
NP.Zeroes | Using Zeros() In Numpy
January 31, 2024 - To create a 2D array, we pass a tuple to the np.zeros function, specifying the number of rows and columns.
🌐
Python Examples
pythonexamples.org › python-numpy-zeros
Create Array with Zeros in NumPy - Examples
To create a two-dimensional array of zeros, pass the shape i.e., number of rows and columns as a tuple for shape parameter to numpy.zeros() function. In this example, we shall create a numpy array with 3 rows and 4 columns. import numpy as np #create 2D numpy array with zeros a = np.zeros((3, ...
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › zeros
Python Numpy zeros() - Create Zero Array | Vultr Docs
January 1, 2025 - Create a 2D or 3D zero array using this shape specification. ... two_d_array = np.zeros((2, 3)) print(two_d_array) three_d_array = np.zeros((2, 3, 4)) print(three_d_array) Explain Code
🌐
datagy
datagy.io › home › numpy › numpy zeros: create zero arrays and matrix in numpy
NumPy Zeros: Create Zero Arrays and Matrix in NumPy • datagy
December 30, 2022 - # Changing data types in zero matrix import numpy as np matrix_2d = np.zeros((3,2), dtype=[('a', 'float'), ('b', 'int')]) print(matrix_2d) # Returns: # [[(0., 0) (0., 0)] # [(0., 0) (0., 0)] # [(0., 0) (0., 0)]]
Find elsewhere
🌐
DigitalOcean
digitalocean.com › community › tutorials › numpy-zeros-in-python
numpy.zeros() in Python | DigitalOcean
Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.zeros.html
numpy.zeros — NumPy v2.2 Manual
Return a new array of given shape and type, filled with zeros · Shape of the new array, e.g., (2, 3) or 2
🌐
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .zeros()
Python:NumPy | Built-in Functions | .zeros() | Codecademy
June 23, 2025 - This example creates a 1D array of five zeros and a 2D array of zeros with shape (3, 2) and integer data type using NumPy’s .zeros() function: import numpy as np · array1 = np.zeros(5) print(array1) array2 = np.zeros((3, 2), dtype=int) ...
🌐
GeeksforGeeks
geeksforgeeks.org › numpy › numpy-zeros-python
numpy.zeros() in Python - GeeksforGeeks
June 15, 2026 - Explanation: np.zeros((3, 4)) creates a 2D array with 3 rows and 4 columns filled with 0.
🌐
DataCamp
datacamp.com › doc › numpy › zeros
NumPy zeros()
import numpy as np array_1d = np.zeros(5) This creates a one-dimensional array with 5 elements, all initialized to zero. array_2d = np.zeros((3, 4), dtype=int) Here, a 3x4 two-dimensional array of integers is created, all initialized to zero. array_3d = np.zeros((2, 3, 4), order='F') This example ...
🌐
Python Guides
pythonguides.com › python-numpy-zeros
Create Arrays Of Zeros In NumPy - Python Guides
May 16, 2025 - When working with data science projects, I often need arrays with more than one dimension. To create multi-dimensional arrays with zeros, simply pass a tuple with the desired dimensions: # Create a 2D array (matrix) with 3 rows and 4 columns matrix = np.zeros((3, 4)) print(matrix)
🌐
YouTube
youtube.com › thispointer academy
np zeros() - Create Numpy Arrays of Zeros (0s) - YouTube
Learn how to create 1D or 2D Numpy Arrays filled with zeros using np.zeros().Topics Covered:1.) numpy.zeros() overview2.) Creating 1D Numpy array of zeros (i...
Published: December 25, 2020
Views: 5K
🌐
Kaggle
kaggle.com › questions-and-answers › 528667
How to fill a Dataframe Matrix with numpy.zeros (columns) and numpy.ones (rows). 26 columns and 2202 rows. | Kaggle
Task You need to create a 2D matrix with 26 columns and 2202 rows, where each column should initially be filled with zeros, and each row should be filled with ones. ... Matrix Size: The matrix has dimensions 2202 rows by 26 columns.