Skip to content

np.transpose() - Transpose an array #45

@TheWolf313

Description

@TheWolf313

Syntax:
np.transpose(a, axes=None)

a: Input array.

axes: Optional. By default, reverses the dimensions (e.g., rows become columns). You can specify the order of axes.

Example:
import numpy as np
transposed = np.transpose(np.array([[1, 2], [3, 4]]))

[[1 3]
[2 4]]

Example 2:

import numpy as np
arr = np.array([[[1, 2], [3, 4]]])
transposed = np.transpose(arr, (0, 2, 1))
print(transposed)

[[[1 3]
[2 4]]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions