Learn to reshape NumPy arrays in 4 minutes! ↔️
Nov 9, 2025•Channel
AI Analysis
Data from YouTube Data API v3•Updated Just now
Video Overview
Video Details
Published6 months ago
Duration4:12
Video IDpgPwaNpC0so
Languageen
CategoryEducation
PrivacyPublic
Made for KidsNo
Video TypeRegular Video
Performance Metrics
Views2.5K
Likes167
Comments26
Engagement Rate7.76%
Likes per 100 views6.71
Comments per 1K views10.45
Description
#python #coding #numpy
# reshape() = Changes the shape of an array
# w/o altering its underlying data
# array.reshape(rows, columns)
import numpy as np
array = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
array = array.reshape(2, 6)
array = array.reshape(3, 4)
# array = array.reshape(4, 4) # Too many elements
# array = array.reshape(2, 4) # Too few elements
array = array.reshape(4, 3)
array = array.reshape(2, 2, 3) # 3D
array = array.reshape(3, 2, 2) # 3D
# -1 NumPy will automatically infer the correct size for that dimension
array = array.reshape(1, -1)
array = array.reshape(-1, 1)
print(array)