Skip to content

numpy ndarray convert function tolist() #147

@YoungBaymax

Description

@YoungBaymax

A float32 ndarray remained 3 decimal places can't be convert to a list properly by using tolist(), but float64 can.

import numpy as np
a = np.random.random((5,))
a64 = a.astype(np.float64)
out64 = np.around(a64, 3)
outlist64 = out64.tolist()
print(outlist64)

a32 = a.astype(np.float32)
out32 = np.around(a32, 3)
outlist32 = out.tolist()
print(outlist32)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions