📖 INDEX
LOADING ENGINE...
np.identity()
AI & DATA SCIENCE // np-identity
Returns the identity array (a square array with ones on the main diagonal).
Syntax
arr = np.identity(4)Examples
Example 01Basic Usage
arr = np.identity(4)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.