BetterDocs
Home
Docs

Creation | np.ogrid()

Method:

np.ogrid= <numpy.lib._index_tricks_impl.OGridClass object>

ogrid provides an alternative to mgrid for indexing and generating coordinate grids. It returns arrays that are less memory-intensive.

Returns:

np.ndarray

If the input is a single slice, returns an array. If the input is multiple slices, returns a tuple of arrays, with only one dimension not equal to 1.
import numpy as np
result = np.ogrid[0:2, 0:5]
print(result)
'''
Output:
[array([[0], [1]]), array([[0, 1, 2, 3, 4]])]
'''

Logo

BetterDocs

Support

EmailDiscordForms

Documentations

Python

Company

AboutDocs

Policies

Terms of ServicePrivacy Policy