DeveloperBreeze

Reshape NumPy Array

The following Python code demonstrates how to reshape a one-dimensional array into a two-dimensional array using NumPy:

import numpy as np

# Define a one-dimensional array
arr = np.array([1, 2, 3, 4, 5, 6])

# Reshape the array into a 2x3 matrix
reshaped_arr = arr.reshape(2, 3)
print(reshaped_arr)

Continue Reading

Handpicked posts just for you — based on your current read.

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!