How to convert a Numpy array of floats to an array of strings in Python

Converting a Numpy array of floats to an array of strings yields an array of formatted strings where each have a specified amount of decimal places.

Solution for How to convert a Numpy array of floats to an array of strings in Python : You can use numpy.ndarray.astype() to convert a Numpy array of floats to an array of strings Call ndarray.astype(string_representation) where string_representation is a string in the format “|Sk” to convert a Numpy array of floats to an array consisting only of strings with k bytes.


how-to-convert-a-numpy-array-of-floats-to-an-array-of-strings-in-python