Skip to content

np.ravel() - Flatten an array into 1D #44

@TheWolf313

Description

@TheWolf313

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

a: Input array.

order: Optional. 'C' means row-major (default), 'F' means column-major, 'A' means Fortran-like if a is Fortran contiguous, otherwise C-like.

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

eg 2
import numpy as np
arr = np.array([[5, 6, 7], [8, 9, 10]])
flat = np.ravel(arr)
print(flat)
[ 5 6 7 8 9 10]

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