BetterDocs
Home
Docs

Creation | np.mgrid()

Method:

np.mgrid= <numpy.lib._index_tricks_impl.MGridClass object>

mgrid is a special object that allows easy creation of mesh grids, often used with slicing to generate coordinate grids.

Returns:

np.ndarray

A single array, containing a set of ndarrays all of the same dimensions. stacked along the first axis.
import numpy as np
result = np.mgrid[0:2, 0:5]
print(result)
'''
Output:
[[[0 0 0 0 0]
  [1 1 1 1 1]]

 [[0 1 2 3 4]
  [0 1 2 3 4]]]
'''

Logo

BetterDocs

Support

EmailDiscordForms

Documentations

Python

Company

AboutDocs

Policies

Terms of ServicePrivacy Policy