📖 INDEX
LOADING ENGINE...
np.eye()
AI & DATA SCIENCE // np-eye
Returns a 2-D array with ones on the diagonal and zeros elsewhere.
Syntax
arr = np.eye(3)Examples
Example 01Basic Usage
arr = np.eye(3)Best Practices
- Refer to the official NumPy documentation for deep vectorization techniques.
- Avoid writing custom Python for-loops for operations that can be vectorized with NumPy.