Skip to content

np.reshape() - Change the shape of an array #43

Description

@TheWolf313

Syntax:
np.reshape(a, newshape, order='C')

Example:
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6])
reshaped = np.reshape(arr, (2, 3))
print(reshaped)

[[1 2 3]
[4 5 6]]

Explanation:
arr is a 1D array: [1, 2, 3, 4, 5, 6]

np.reshape(arr, (2, 3)) reshapes it into a 2D array with 2 rows and 3 columns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions